0

This is the error

Warning: Cannot modify header information - headers already sent by (output started at /home/rejocoma/public_html/login-registor/do_login.php:9) in /home/rejocoma/public_html/login-registor/do_login.php on line 40

and this comming only on my hosting not in local machine ita unix hosting solution

can any one give me a help on this im a new in php and pleas give me a help...

Thank you.........

Edited by ruwanaru: n/a

4
Contributors
9
Replies
10
Views
7 Years
Discussion Span
Last Post by venkat0904
0

u must be using header() function after ur output has started...
mind it header() cant be used once you started sending some output to ur browser.. not even a single blank space...

Post up the code if u need more clarification on this

This is the error

Warning: Cannot modify header information - headers already sent by (output started at /home/rejocoma/public_html/login-registor/do_login.php:15) in /home/rejocoma/public_html/login-registor/do_login.php on line 6

and this comming only on my hosting not in local machine ita unix hosting solution

can any one give me a help on this im a new in php and pleas give me a help...

Thank you.........

Edited by venkat0904: n/a

0

This is my codes what is the wrong with this :(

<?php 
session_start();              


include("../init/db.php");
$uname=$_POST['uname'];
$pass=$_POST['pass'];

echo $uname."<br />";
echo $pass;
$res ="";


$sql = "SELECT * FROM `users` WHERE uname='$uname'";
$result = mysql_query($sql);
$row=mysql_num_rows($result);

if($row==1){

	while($info=mysql_fetch_array($result)){	
		$pa=$info['pass'];
	
		if($pass==$pa){
			echo "pssaword mach";
			$_SESSION['LOGGED']=true;
			$_SESSION['uname']=$info['uname'];
			$_SESSION['fname']=$info['fname'];
                         header("Location:../usercp.php");                    
					
			}
		else{
			echo "password not mach";
			$res ="password not mach";
			header("Location:../login.php?error=2");
			}
		}
}else{
	
	echo "username dos not mach";
	header("Location:../login.php?error=1");
	}

?>
1

As i said, u cant use header after sending output to browser(echo statements in this case)... Remove all echo statements before header or use them after it... though it wont get displayed in ur browser if u use them after header...
Cheers!

This is my codes what is the wrong with this :(

<?php 
session_start();              


include("../init/db.php");
$uname=$_POST['uname'];
$pass=$_POST['pass'];

echo $uname."<br />";
echo $pass;
$res ="";


$sql = "SELECT * FROM `users` WHERE uname='$uname'";
$result = mysql_query($sql);
$row=mysql_num_rows($result);

if($row==1){

	while($info=mysql_fetch_array($result)){	
		$pa=$info['pass'];
	
		if($pass==$pa){
			echo "pssaword mach";
			$_SESSION['LOGGED']=true;
			$_SESSION['uname']=$info['uname'];
			$_SESSION['fname']=$info['fname'];
                         header("Location:../usercp.php");                    
					
			}
		else{
			echo "password not mach";
			$res ="password not mach";
			header("Location:../login.php?error=2");
			}
		}
}else{
	
	echo "username dos not mach";
	header("Location:../login.php?error=1");
	}

?>

Edited by venkat0904: n/a

0

yeah none will work... actually looking at your code i feel there is no need of those echo statements there... may i suggest u to remove all those echo statements. Any header after an echo statement wont work

any of those headers are not working

1

Not only echo, you will get this warning if you have session_start along with header function. Use

ob_start();

as the first line of your script to turn on output buffering and

ob_end_flush();

as the last line to flush the output to the buffer.

0

yeah i missed that... nice info !!!

Not only echo, you will get this warning if you have session_start along with header function. Use

ob_start();

as the first line of your script to turn on output buffering and

ob_end_flush();

as the last line to flush the output to the buffer.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.