Why the warning is showing and the header is not sendingwith this script?

<?php
function authenticateUser($user,$password)
{
$con=mysql_connect("localhost","root","");
mysql_select_db("niladri",$con);
$sql="select * from user_profile where user_id='$user'and password='$password'";
$res=mysql_query("$sql",$con);
if( ($row = mysql_fetch_array($res)) && ($user_id==$row["user"])&&($password == $row["password"] ) && ($password !="") )
return 1;
else
return 0;
}
?>
<?php
$form_user_id=$_POST;
$form_password=$_POST;
if(authenticateUser($form_user_id,$form_password))
{
echo"Your userID and password are correct";
setcookie("cookie_passwd",$form_password,time()+3600);
setcookie("cookie_user",$form_user_id,time()+3600);
header("Location:search.html");
exit();
}
else
{
echo"the page cannot be displayed/the password and or userID is not correct";
}
?>

The warnings are:

Your userID and password are correct
Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files\xampp\htdocs\Niladri's PHP Programs\PROJECT SHOP\index\login1.php:19) in C:\Program Files\xampp\htdocs\Niladri's PHP Programs\PROJECT SHOP\index\login1.php on line 20

Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files\xampp\htdocs\Niladri's PHP Programs\PROJECT SHOP\index\login1.php:19) in C:\Program Files\xampp\htdocs\Niladri's PHP Programs\PROJECT SHOP\index\login1.php on line 21

Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files\xampp\htdocs\Niladri's PHP Programs\PROJECT SHOP\index\login1.php:19) in C:\Program Files\xampp\htdocs\Niladri's PHP Programs\PROJECT SHOP\index\login1.php on line 22


please send me a quick reply!! :-O

You SHOULDN'T echo anything before header and setcookie functions.

Edit: Not even a whitespace.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.