Dit is mijn code voor in/uitloggen met cookies. Het gaat fout als ik $autologin aanvink, dan logt hij neit meer uit. Als ik dat neit aan heb gevinkt logt hij wel gewoon uit.
PHP:
1
| <? include('config.php'); mysql_connect("$host", "$user", "$pass"); mysql_select_db("$db"); $Query = mysql_query("SELECT * FROM members"); $Results = mysql_num_rows($Query); if($password == md5(($password))) { if($logout) { setcookie("username", "", -1, "/"); setcookie("password", "", -1, "/"); header("Location: ./"); exit;} else { echo "Je bent ingelogd als $username, <a href=\"login.php?logout=1\">uitloggen?</a>"; } } else { if ($HTTP_POST_VARS["login_user"] && $HTTP_POST_VARS["login_password"]) { $pass = md5($HTTP_POST_VARS["login_password"]); $check_pass = md5(($HTTP_POST_VARS["login_user"])); if($pass == $check_pass) { if($autologin) { setcookie("username", $HTTP_POST_VARS["login_user"], time()+(30 * 24 * 3600), "/"); setcookie("password", $pass, time()+(30 * 24 * 3600), "/"); header("Location: ./"); exit;//}else { setcookie("username", $HTTP_POST_VARS["login_user"], time()+5, "/"); setcookie("password", $pass, time()+5, "/"); header("Location: ./"); exit; } } else { echo "foute gebruikersnaam of wachtwoord."; //jammer dan :D } } else { echo " <html> <head> <title>Login</title> </head> <body> <strong>Login</strong> <form action=\"login.php\" method=\"post\"> Username:<br> <input type=\"Text\" name=\"login_user\"><p> Password:<br> <input type=\"Password\" name=\"login_password\"><p> <input class=\"text\" type=\"checkbox\" name=\"autologin\" />Log me automatisch in bij een volgend bezoek.<BR><BR> <input type=\"Submit\" value=\" Login! \"> </form> </body> </html> "; } } ?> ?> |