Jump to content

Cannot Modify Header Information


MrFish

Recommended Posts

I'm trying to use ajax to log in users, but I get this error message.

Warning: Cannot modify header information - headers already sent by (output started at /home/mandala/public_html/includes/loginhandler.php:20) in /home/mandala/public_html/includes/loginhandler.php on line 22Warning: Cannot modify header information - headers already sent by (output started at /home/mandala/public_html/includes/loginhandler.php:20) in /home/mandala/public_html/includes/loginhandler.php on line 23
The Login handler code is.
<?	session_start();		$con = mysql_connect("localhost", "username", "password") or die(mysql_error());	mysql_select_db("mandala_maindb");		$username = mysql_real_escape_string($username);	$password = mysql_real_escape_string($password);		$query="SELECT * FROM users WHERE username ='$username'";	$run = mysql_query($query);	$results = mysql_affected_rows();		if($results!=1){		//The username doesn't exist		echo 'username false';		return false;	}		$query="SELECT * FROM users WHERE username='$username' AND password='$password'";	$run = mysql_query($query);	$results = mysql_affected_rows();		if($results==1){		//login success		echo 'login true';		$_SESSION["username"] = $username;		setCookie("username", $username, time()+60*60*24*30,'/');		setCookie("password", $password, time()+60*60*24*30,'/');	} else {		echo 'login false';		return false;	}?>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...