Jump to content

Header Not Redirecting


iMiles

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/210928-header-not-redirecting/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.