I'm writing a very simple clean login session as a demonstration to friends. I've been over this code a lot of times and can't fault it, but obviously I am wrong.. or maybe xampp is just having one of those days.
Undefined Index: username on line 30, login.php
all files involved are attached. Thanks in advance.
<?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("login") or die("couldn't find db");
$query = mysql_query("SELECT * FROM users WHERE username='$username'");
$numrows = mysql_num_rows($query);
if ($numrows!=0)
{
//login code
while ($row = mysql_fetch_assoc($query))
{
$dbusername = $row['username'];
$dbpassword = $row['password'];
}
//check is pass & user match
if ($username==$dbusername&&$password==$dbpassword)
{
echo "you're in click here to enter the <a href='member.php'>member page</a> haha";
$_SESSION['username']==$dbusername;
}
else
echo "incorrect password";
}
else
die("that user doesn't exist");
}
else
die("failed to connect")
?>
[attachment deleted by admin]