PHP-FORM POST problems

Discussion in 'PHP' started by lighthazard, Aug 29, 2007.

  1. #1
    I am having a simple problem, I don't know how to address. I tried using g00gle but it didn't help much. I am designing a few "login" forms or even registration forms for a site of mine. I can login fine when I CLICK the login button. However, I know a lot of people, including myself, like to press the enter key on our keyboard to send the data.

    My problem is simple, when people use the enter key, and not click the button, the form posts ONLY the username, the password isn't even sent. The code is very simple, inside a <td> of a <table>:
        
    <form method="POST" action="">
        <input onFocus="this.value=''" class="text1" type="text" name="username" value="Username"/>
        <input onFocus="this.value=''" class="text1" type="password" name="password" value="Password"/>
    
        <input type="submit" name="submit" value="Login"/>
        </form>
    
    Code (markup):
    This has happened on multiple sites of mine. I don't know if it's just my coding, or the browser, or both. I'd really appreciate help on that.
     
    lighthazard, Aug 29, 2007 IP
  2. killerj

    killerj Active Member

    Messages:
    765
    Likes Received:
    34
    Best Answers:
    0
    Trophy Points:
    95
    #2
    is the form being submitted to the right file ?
    try this :
    <form method="POST" action="USeyourformnamehere.php">
     
    killerj, Aug 29, 2007 IP
  3. mad4

    mad4 Peon

    Messages:
    6,986
    Likes Received:
    493
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Is the code to process the form collecting all the variables in the same way?
     
    mad4, Aug 29, 2007 IP
  4. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #4
    Maybe because your onFocus="this.value=''" deletes the value before submitting? Try this instead.

    
    onFocus="if (this.value == this.defaultValue) this.value = '';"
    
    Code (markup):
     
    nico_swd, Aug 29, 2007 IP
  5. lighthazard

    lighthazard Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Hey! That solved the problem. thanks a lot!
     
    lighthazard, Aug 29, 2007 IP