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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.