Page 1 of 1

header error

Posted: Mon Jul 30, 2007 6:40 pm
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'];
		}

Re: header error

Posted: Mon Jul 30, 2007 6:45 pm
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().

header error

Posted: Mon Jul 30, 2007 7:14 pm
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