header('Location: ); redirection not working.....

I can NOT figure out why this code won’t work. It seems to work fine in the tutorial I followed. I have the code copied the exact same way the tutorial said to. and ive googled my problem and can’t figure it out… when I press the “Login!” button on my login.php file, the page does not redirect to admin.php… here is my code… in my, “if else” statement, the else will echo text, but when i try to make the else redirect to a new session it won’t work, it just loads a blank login.php page… here is my code and the youtube tutorial I followed… http://www.youtube.com/watch?v=IPahfwPjEhI… If you can figure it out email [email protected] thank you so much!!!

login.php
[php]

<?php mysql_connect("localhost", "FoleyHurley", "zephyr12"); mysql_select_db("blog1"); ?> Login <?php if(isset($_POST['submit'])){ $name = $_POST['name']; $pass = $_POST['password']; $result = mysql_query("SELECT * FROM users WHERE name='$name' AND pass='$pass'"); $num = mysql_num_rows($result);
	if($num == 0) {
		echo "Bad login go <a href='login.php'>back</a>";
	}else{

//I BELIEVE THE PROBLEM HAS SOMETHING TO DO WITH THE FOLLOWING 3 LINES… HELP!
session_start();
$_SESSION[‘name’] = $name;
header(‘Location: admin.php’);
}

	}
	
	else{
	?>
	
	<form action='login.php' method='post'>
		
		Username: <input type='text' name='name' /><br />
		Password: <input type='password' name='password' /><br />
		<input type='submit' name='submit' value='Login!' />
		
	</form>
	<?php
	}
	?>
</body>
[/php]

Is admin.php in the same folder as the login script?

See the below quote from the online PHP manual site (http://www.php.net/manual/en/function.header.php):

That is to say, lines 5-9 are output, therefore nullifying the above statement and stopping your header function from being processed.

Sponsor our Newsletter | Privacy Policy | Terms of Service