I have been using the same as written. But whenever I click on it, it gives an error
Notice: Undefined index: username in D:\xamp\htdocs\xampp\new\login.php on line 3
Notice: Undefined index: password in D:\xamp\htdocs\xampp\new\login.php on line 4
please enter username and password
My HTML is:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form action="login.php" method="POST">Username:
<input type ='text' name="username" /><br />
password<input type="password" name="password" /><br />
<input type="submit" value="login" /></form>
</body>
</html>
While my PHP is:
<?php
$username = '$_POST[username]';
$password = '$_POST[password]';
if($username && $password)
{
$connect = mysql_connect(“localhost”, “root”, “”);
$query=mysql_query("SELECT * FROM usres WHERE username=$username");
$numrows = mysql_num_rows($query);
if (!connect) {
die('Connection Failed: ' . mysql_error());
}
mysql_select_db(“phplogin”, $connect);
}else{
die("please enter username and password");
enter code here
}
?>