Notice: Undefined index

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jeferson
    New Member
    • Sep 2010
    • 1

    #1

    Notice: Undefined index

    <form name="form1" method="post" action="login.p hp">
    <table cellpadding="0" cellspacing="0" border="0">
    <tr>
    <td><img src="mlogin.gif " alt=""></td>
    </tr>
    <tr>
    <td width="162" height="82" background="mbg .gif" align="center"> <table cellpadding="0" cellspacing="0" class="fontb2">
    <tr>
    <td> Username:</td>
    </tr>
    <tr>
    <td> <input type="text" name="username" value="" style="height: 20px; width: 120px;"></td>
    </tr>
    <tr>
    <td> Password:</td>
    </tr>
    <tr>
    <td> <input type="password" name="password" value="" style="height: 20px; width: 120px;"></td>
    </tr>
    <tr>
    <td></td>
    </tr>
    </table></td>
    </tr>
    <tr>
    <td><a href="index_pri ncipal.php?link =8"><img src="login.gif" alt="" border="0"></a></td>
    </tr>
    </table>
    </form></td></tr></table>



    then on login.php i have got

    <?php

    $username=$_POS T["username"] ;
    $password=$_POS T["password"] ;


    echo "{$username }: {$password}" ;

    ?>

    i am using echo to check if it's working only! but it's NOT!!! i don't know why?????? help please!
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    Works fine for me.

    Are you trying to load login.php without actually submitting the form? If you are, then there will be no data in the POST array. You should be checking that the data exists before trying to use it.

    Code:
    if ( ! isset($_POST['username']) )
    {
      print "No username given<br />";
    }
    else
    {
      $username = $_POST['username'];
    }
    Mark.

    P.S. Use [code] your code here [/code] when posting code.

    Comment

    Working...