This question already has an answer here:
I am getting this error
Notice: Undefined index: username in C:\xampp\htdocs\login.php on line 24
Notice: Undefined index: password in C:\xampp\htdocs\login.php on line 25
on this code
<?php
session_start();
$username = $_POST['username'];
$password = $_POST['password'];
if ($username&&$password)
{
$connect = mysql_connect("localhost","root","") or die ("couldn't connect");
mysql_select_db("test") or die ("couldn't find DB");
$query = mysql_query("select * FROM users WHERE username='$username'");
$numrows = mysql_num_rows($query);
if($numrows!=0)
{
//login goahead
while ($row = mysql_fetch_assoc($query))
{
$dbusername = $row['username'];
$dbpassword = $row['password'];
if($username==$dbusername&&$password==$dbpassword)
{
echo "You're in! <a href='member.php'>click here to continue</a>";
$_SESSION['username']=$username;
}
else
echo"Incorrect Password";
}
}
else
die("That user does not exist!");
}
else
die("please enter a username and password");
?>
I have tried changing around where the if statement that checks DB username and pass that is and tried to redefine the calls but it wont work. any help will be great.
</div>