Log in ';
exit(); // exit the current script, no value is returned
}
if (isset($_POST['user']))
{
$user = trim($_POST['user']);
if (!ctype_alnum($user)) // ctype_alnum() check if the values contain only alphanumeric data
reject('User Name');
if (isset($_POST['pwd']))
{
$pwd = trim($_POST['pwd']);
if (!ctype_alnum($pwd))
reject('Password');
else
{
// setcookie(name, value, expiery-time)
// setcookie() function stores the submitted fields' name/value pair
setcookie('user', $user, time()+3600);
// setcookie('pwd', md5($pwd), time()+3600); // create a hash conversion of password values using md5() function
// setcookie('pwd', password_hash($pwd, PASSWORD_DEFAULT), time()+3600); // password_hash() requires at least PHP5.5
// setcookie('pwd', password_hash($pwd, PASSWORD_BCRYPT), time()+3600);
// relocate the browser to another page using the header() function to specify the target URL
header('Location: cookie-get.php');
}
}
}
else
header('Location: cookie-form.html');
?>