I am working on how to redirect to another page by suing header() function, but it’s not working, and give me an error message saying hat:Cannot modify header information – headers already sent by…… Anyone could help, thanks a lot.
here is my php code
if(isset($_POST['email'])){
$email = $_POST['email'];
$pass = $_POST['pass'];
$query = "select email, password from member where email = '$email' and password='$pass'";
if(mysql_num_rows(queryMysql($query)) == 0)
{
echo "Email/Password invalid<br/>";
}
else
{
$query1 ="select uniid from member where email = '$email' and password ='$pass'";
$result1 = queryMysql($query1);
$row1 = mysql_fetch_object($result1);
$uniid = $row1->uniid;
$_SESSION['uniid'] = $uniid;
header("Location:View.php?view=$uniid");
}
}
Consider starting your code with
ob_start(). This turns off output buffering, which in short allows you to useheader()andsetcookie()anywhere at all.