This question already has an answer here:
Can anyone help with this error? I would like to make log in session in my system. Here is the coding.
<?PHP
error_reporting (E_ALL^E_NOTICE);
session_start();
$username =$_POST['username'];
$password =$_POST['password'];
if ($username && $password)
{ // if 1
$server='localhost';
$userid2='root';
$password2='';
$dbname='suhaibah';
$conn=mysql_connect("$server", "$userid2", "$password2");
mysql_select_db("$dbname", $conn) or die(mysql_error());
$query = mysql_query("select * from staff where username = '$username'");
$numrows = mysql_num_rows($query);
if ($numrows !=0)
{ // if 2
while ($row = mysql_fetch_assoc($query))
{ // if 3
$dbusername = $row['username'];
$dbpassword = $row['password'];
} // if 3
if ($username==$dbusername&&$password==$dbpassword)
{
//echo "You're in! <a href='index2.php'>click </a> here to enter";
$_SESSION['username']=$username;
header( 'Location: http://localhost/novel/lamanutamaadmin.php' ) ;
}
else
{echo " Incorrect Password!! <a href='/novel/landingpageadmin.php'>Click here to login</a>";}
} // if 2
else
die (" That user dosen't exist<a href='/novel/landingpageadmin.php'>Click here to login</a>");
} // if 1
else
{
echo "Please enter userid and password!!<a href='/novel/landingpageadmin.php'>Click here to login</a>";
}
?>
</body>
</html>
</div>