iMiles Posted August 17, 2010 Share Posted August 17, 2010 As the title says, my headers not redirecting. Login.php: <?php include("global.php"); if (isset($_POST['login'])) { // Form data $email = $_POST['email']; $password = $_POST['password']; // If email and password are both filled in if ($email && $password) { mysql_select_db("social_site") or die("Can\'t find database!"); $query = mysql_query("SELECT * FROM users where email = '$email'"); $numrows = mysql_num_rows($query); // If email in database if ($numrows != 0) { // Login while ($row = mysql_fetch_assoc($query)) { $dbemail = $row['email']; $dbpassword = $row['password']; } if ($email == $email && $password == $dbpassword) { // User is logged in header(' location: index.php '); } else { echo "Incorrect password."; } } else { echo "That email does not exist."; } } else { echo "Please fill in <strong>all</strong> fields."; } } ?> <p> <html> <form action = 'login.php' method = 'POST'> Email: <input type = 'text' name = 'email'> <p> Password: <input type = 'text' name = 'password'> <p> <input type = 'submit' name = 'login' value = 'Login'> </form> </html> Global.php: <?php // This is the global file for the entire website // Start a session session_start(); // Start MySQL connection mysql_connect('localhost', 'root', 'root'); ?> Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/210928-header-not-redirecting/ Share on other sites More sharing options...
trq Posted August 17, 2010 Share Posted August 17, 2010 Make sure you have error reporting set to E_ALL and display errors on. <?php error_reporting(E_ALL) ; ini_set('display_errors', '1'); ?> Quote Link to comment https://forums.phpfreaks.com/topic/210928-header-not-redirecting/#findComment-1100196 Share on other sites More sharing options...
charles.ca Posted August 17, 2010 Share Posted August 17, 2010 This is what i am using . its working perfectly . header("Location:index.php"); Quote Link to comment https://forums.phpfreaks.com/topic/210928-header-not-redirecting/#findComment-1100249 Share on other sites More sharing options...
iMiles Posted August 17, 2010 Author Share Posted August 17, 2010 This is what i am using . its working perfectly . header("Location:index.php"); Ah, that fixed it. Thanks both for your replies Quote Link to comment https://forums.phpfreaks.com/topic/210928-header-not-redirecting/#findComment-1100389 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.