Jump to content

Cannot Modify Header Information


MrFish
 Share

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...