How do I print a string to the screen in a specific location

Discussion in 'PHP' started by Imozeb, Feb 5, 2010.

  1. #1
    How do I print an error message, "Username already taken!" to a specific location on the screen i.e. above the desired user name input box? Is there any way I can do this without the user losing all her input? (note: the PHP script is in the header not in the body tag next to the form)

    Thanks in advance! :)

    ~Imozeb
     
    Imozeb, Feb 5, 2010 IP
  2. JAY6390

    JAY6390 Peon

    Messages:
    918
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #2
    assign the error to a variable and then echo the error above the username
    you could also use ajax to check this and report the error without even refreshing the page
     
    JAY6390, Feb 5, 2010 IP
  3. JAY6390

    JAY6390 Peon

    Messages:
    918
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #3
    You could save the error to a variable then echo the variable out above the text box

    You could also use AJAX to check it without refreshing the page
     
    JAY6390, Feb 5, 2010 IP
  4. Imozeb

    Imozeb Peon

    Messages:
    666
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    OMG! I can't believe I didn't think of that and I know a few other programming languages, proves that I'm still a noob at PHP as I just started learning it a few weeks ago. :)

    Thanks!

    ~Imozeb :)
     
    Imozeb, Feb 6, 2010 IP