I have an error on line 2 and 3, that says undefined index: username,undefined index: password, can you help me about this? All find, set a cookie is ok but I got a display error in the pageSee the picture
<?php
$cookie_name = $_POST['Username'];
$cookie_value =$_POST['password'];
$mysql_host = "localhost";
$mysql_user = "root";
$mysql_password = "";
$mysql_database = "try";
mysql_connect($mysql_host, $mysql_user, $mysql_password);
mysql_select_db($mysql_database);
if (isset($_POST['username'])) {
$username = $_POST['username'];
$password = $_POST['password'];
$sql = "SELECT * FROM user WHERE usern='".$username."' AND userp='".$password."' LIMIT 1";
$res = mysql_query($sql);
if (mysql_num_rows($res) == 1) {
if (isset($_POST['rememberme'])) {
/* Set cookie to last 1 year */
setcookie("$cookie_name", "$cookie_value", time()+60*60*24*365, "/");
} else {
}
header('Location: index.php');
exit();
} else {
echo "<script type='text/javascript'>alert('Invalid Username or Password or Account not Registered!')</script>";
echo "<script> window.location.assign('index1.php'); </script>";
exit();
}
}
?>
<input type="text" value="" placeholder="Username" name="username"/>
<input type="password" value="" placeholder="Password" name="password"/>
Remember Me: <input type="checkbox" name="rememberme" value="1">
<button><input type="submit" name="submit" value="Sign In"/></button><br><br>