Flames Posted October 10, 2008 Share Posted October 10, 2008 some bad logic in my php login script seems to crash firefox due to redirect loop error i cant seem to find any bad logic in it, maybe it just needs someone else to spot it. <?php session_start(); $db_user = ""; $db_name = ""; $db_pass = ""; $db_host = "localhost"; //Form Variables $login = $_POST['login']; $user = $_POST['username']; $pass = $_POST['password']; $pass2 = md5($pass); $r_me = $_POST['rememberme']; $connect = mysql_connect($db_host, $db_user, $db_pass) or die("cannot connect error: " . mysql_error()); mysql_select_db($db_name, $connect); if(!isset($login) && !isset($logout)) { if(!session_is_registered("user")||!session_is_registered("pass")) { ?> <html> <body><center> <form method="post" action="login.php" id="login" name="login"> <input type="hidden" name="login" value="true" /> Username : <input type="text" name="username" /><br /> Password : <input type="password" name="password" /><br /> Remember Me <input type="checkbox" name="rememberme" value="true" /><br /> <input type="submit" value="Login"> </form></body></center></html> <?php } else { header("location:user.php"); } } elseif($login == "true") { $sql = "SELECT * FROM Account WHERE username = '$user' AND password = '$pass2'"; $query = mysql_query($sql); $count = mysql_num_rows($query); if($count==1){ session_register("user"); session_register("pass"); header("location:user.php"); } else { echo "<center>Wrong Username or Password</center>"; } } elseif($logout == "true") { session_destroy(); echo "<center>You have logged out successfully</center>"; } else { if(!session_is_registered("user")||!session_is_registered("pass")) { echo "<center>Please Use The Login Form</center>"; } else { header("location:user.php"); } } ?> note exact FF error Redirect Loop Redirection limit for this URL exceeded. Unable to load the requested page. This may be caused by cookies that are blocked. The browser has stopped trying to retrieve the requested item. The site is redirecting the request in a way that will never complete. * Have you disabled or blocked cookies required by this site? * NOTE: If accepting the site's cookies does not resolve the problem, it is probably a server configuration issue and not your computer. Link to comment https://forums.phpfreaks.com/topic/127912-bad-logic-creates-redirect-loop-error-in-ff/ Share on other sites More sharing options...
fanfavorite Posted October 10, 2008 Share Posted October 10, 2008 It probably has to do with your "user.php". Do you do a check on that page as well? Please post this is you need help. Link to comment https://forums.phpfreaks.com/topic/127912-bad-logic-creates-redirect-loop-error-in-ff/#findComment-662282 Share on other sites More sharing options...
Flames Posted October 10, 2008 Author Share Posted October 10, 2008 user.php <?php if(!session_is_registered("user")||!session_is_registered("pass")) { echo "javascript: alert(\"Please Login\")"; header("location:login.php"); } ?> Link to comment https://forums.phpfreaks.com/topic/127912-bad-logic-creates-redirect-loop-error-in-ff/#findComment-662288 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.