...

View Full Version : Notice: Undefined index: password



USB
04-15-2012, 02:39 PM
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
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

tangoforce
04-15-2012, 03:05 PM
Somewhere near the top of your script, you need to do this:
var_dump($_POST);

That will show you what is being sent.

USB
04-15-2012, 03:50 PM
it seems like its not sending the password.

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

tangoforce
04-15-2012, 04:38 PM
Well there you go then. The password isn't being sent for some reason. Do you type text into it?

tangoforce
04-15-2012, 04:40 PM
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"



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


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

It's 'name' NOT 'nanme' :thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum