header error

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
krraleigh
Forum Commoner
Posts: 86
Joined: Tue Jul 17, 2007 2:52 pm

header error

Post by krraleigh »

I thought that IF you used header('location: ...'); before any html you would be alright.
But, for some reason I have a header error that states:

Warning: Cannot modify header information - headers already sent by (output started at G:\xampp\htdocs\bethel\1purpose_bethel\forgotPass.php:5) in G:\xampp\htdocs\bethel\1purpose_bethel\forgotPass.php on line 16

line 16 is the line that shows header('location: ...');

Here is a code fragment. I don't think you need to see the whole page, but if you do let me know?

Thank You
Kevin

Code: Select all

<?php if (isset($_POST['Submit'])){
	
	//Place quotes around the email address so that when you compare it, it will match.
	//note the special handling of the variable in the sql query string
	$myEmail = quote($_POST['email']);
	$check = mysql_query("SELECT * FROM user WHERE email = \"$myEmail\"")or die(mysql_error());
	
  //Gives error if user dosen't exist
  $check2 = mysql_num_rows($check);
  if (empty($check2)) {	  
	  $_SESSION['SES_loginErr'] = "Your email address was not found in the database, please try again!";
	  header('Location: forgotPass.php');
	  exit;
  } else {
  		
		while($info = mysql_fetch_array( $check )) {
 			$fName = $info['fName'];
		}
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Re: header error

Post by superdezign »

krraleigh wrote:Warning: Cannot modify header information - headers already sent by (output started at G:\xampp\htdocs\bethel\1purpose_bethel\forgotPass.php:5) in G:\xampp\htdocs\bethel\1purpose_bethel\forgotPass.php on line 16
It says you make output on line 5, before your call to header().
krraleigh
Forum Commoner
Posts: 86
Joined: Tue Jul 17, 2007 2:52 pm

header error

Post by krraleigh »

I found my problem and I appreciate your time.
Simply put I was outputing blank lines.

I had two blank lines above my php tag

Kevin :D
Post Reply