Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    USB
    USB is offline
    New Coder
    Join Date
    Jan 2012
    Posts
    29
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Notice: Undefined index: password

    hi, what is wrong with this code? i'm getting this notice "Notice: Undefined index: password in C:\wamp\www\login.php on line 6"

    PHP Code:
    <?php
    include('config.php');

    if(
    $_SERVER['REQUEST_METHOD'] =='POST') {
        
    $username mysql_real_escape_string($_POST['username']);
        
    $password mysql_real_escape_string(md5($_POST['password']));
        
        
        
    $query mysql_query("SELECT * FROM users WHERE username='$username' AND password='$password'");
        
    $query_rows mysql_num_rows($query);
        
      if(
    $query_rows 0) {
          echo(
    "Succesfull login!");
          
        
    session_start();
        
    $_SESSION['login'] ="1";
      }
      else
      {
          echo(
    "Bad login!");
      }
    }
    ?>
    <html>
        <head>
            <title>Login</title>
        </head>
        <body>
            <form action="login.php" method="post"/>
            Username: <input type="text" name="username" /><br />
            Password: <input type="password" nanme="password" /><br />
            <input type="submit" value="Login" />
         </form>
         </body>
    </html>
    //Max

  • #2
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,093
    Thanks
    51
    Thanked 506 Times in 493 Posts
    Somewhere near the top of your script, you need to do this:
    var_dump($_POST);

    That will show you what is being sent.
    My helpful sig is on vacation trying to loose some weight. It got a bit fat and caused a few problems but it will be back at some point!

  • #3
    USB
    USB is offline
    New Coder
    Join Date
    Jan 2012
    Posts
    29
    Thanks
    5
    Thanked 0 Times in 0 Posts
    it seems like its not sending the password.

    array
    'username' => string 'Max' (length=3)

  • #4
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,093
    Thanks
    51
    Thanked 506 Times in 493 Posts
    Well there you go then. The password isn't being sent for some reason. Do you type text into it?
    My helpful sig is on vacation trying to loose some weight. It got a bit fat and caused a few problems but it will be back at some point!

  • #5
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,093
    Thanks
    51
    Thanked 506 Times in 493 Posts
    Quote Originally Posted by USB View Post
    hi, what is wrong with this code? i'm getting this notice "Notice: Undefined index: password in C:\wamp\www\login.php on line 6"

    PHP Code:
            Password: <input type="password" nanme="password" /><br /> 

    There you go, you've spelt 'name' incorrectly.

    It's 'name' NOT 'nanme'
    My helpful sig is on vacation trying to loose some weight. It got a bit fat and caused a few problems but it will be back at some point!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •