Hi everyone
I'm new for php i watch tutorial user login and log out and i just follow the code but when i try it i have an error like this:Notice: Undefined index: username in C:\xampp\htdocs\xampp\member.php on line 5
and this is my code for login
<?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("phplogin") or die ("Couldn't find DB");
$query = mysql_query("SELECT * FROM users WHERE username = '$username'");
$numrows = mysql_numrows($query);
if ($numrows!=0)
{
while ($row = mysql_fetch_assoc($query))
{
$dbusername = $row['username'];
$dbpassword = $row['password'];
}
if ($username==$dbusername&&$password==$dbpassword)
{
echo "your login <a href='member.php'>Click</a> here to enter the member page.";
$_SESSION['username']==$dbusername;
}
else
echo "Incorrect password";
}
else
die("That user doesn't exist");
}
else
die("Please enter a username or Password");
?>
and other code for membership.php
<?php
session_start();
echo "Welcome, ".$_SESSION['username']."!<br><a href='logout.php'>Logout</a>"; <== THIS IS MY ERROR
?>