Possible Duplicate:
Headers already sent by PHP
Greets All... I am new to PHP and i am trying to make a login page .the problem which i am facing is the header in If condition gives me error and so i cant redirect to the next page if $reg and $password matches with that in database. secondly do you think that its the best way which i am doing in this code? sorry for my bad english Here is my code..
<?php
$reg=$_POST["reg"];
$password=$_POST["pwrd"];
$result=mysql_query("Select * from student where reg='$reg' and password='$password'");
if(!$result){
die('errrrrrrrrrrrrror'.mysql_error());
}
while ($row = mysql_fetch_array($result)) {
$db_reg=$row['reg'];
$db_password=$row['password'];
}
if(isset($_POST['login'])){
if($reg!=$db_reg || $password!=$db_password){
echo 'login failed';
}
//else if($reg=="" || $password!=""){
// echo 'empty';
//}
else if($reg==$db_reg && $password==$db_password){
header("Location:welcome.php");
//echo 'weclome here'." ".$reg;
}
}
?>