I put "username" and "password" to a form of mine. The action starts up a handler.php. The user sees then only a white page (handler.page) if he does not reload his browser at handler.php. If he does, the handler puts him to back to index.php.
Ben o bir giriş-çerez alır handler.php kaldıktan sonra geri ana sayfasına otomatik olarak kullanıcıyı koymak istiyorum.
Ben benim handler.php de şu var
$email = $_POST['email'];
$username = $_POST['username'];
$passhash_md5 = $_POST['passhash_md5'];
// COOKIE setting
/* $cookie may look like this
variables
$username = "username"$
$passhash_md5 = "password"$
$email ="email"$
$_SERVER['REMOTE_ADDR']=11.44.23.94$
before md5:$
"usernamepasshash_md5email11.44.23.94"$
after md5:$
"a08d367f31feb0eb6fb51123b4cd3cb7"$
*/
$login_cookie = md5(
$username .
$password .
$email .
$_SERVER['REMOTE_ADDR']
);
setcookie ("login", $login_cookie);
if (isset($_COOKIE['login']) )
{
$sql2 = "SELECT * from users";
$raw_user_list = pg_query($dbconn, $sql2);
$user_list = pg_fetch_all($raw_user_list);
// to process each user in the user-list that has a password
foreach ($user_list as $user => $passhash_md5)
{
//match the user list with the cookie$
if ( $login_cookie == $_COOKIE['login'] )
{
header("Location: index.php");
die("logged in");
}
}
header("Location: index.php");
die("wrong username/password");
}
?>
Ben POST-yöntemini kullanır ve eylem handler.php bir form var.
My form
<form method="post" action="handler.php">
<p>Username:
<input name="username" type="text" size="40" />
</p>
<p>Email:
<input name="email" type="text" size="230" />
</p>
<p>Password:
<input name="password" type="password" size="230" />
</p>
<input type="submit" value="OK" />
</form>
Işleyici sayfa AJAX tarafından denir değil.
Ben HEAD ile başarısız işleyici sayfayı çalıştırın:
<head>
<meta http-equiv="refresh" content="5; URL=inedx.php">
</head>
PHP header-komutları kullandığınızda çıkış için izin vermez, çünkü Ancak, HEAD içeremez.
How can you put the user automatically to the index.php if the login is successful?