Please help me to connect my header… Is there something to encode before or after the header location?
Hi @ricangela!
Headers must be sent before any other data output. Otherwise you should add
php_flag output_buffering on
to .htaccess
and make use of ob_start()/ob_end_flush()
1 Like
<?php
require 'dbconnect.php';
$u = $_POST['user'];
$p = sha1($_POST['pas']);
$s = 0;
$sql = "SELECT * FROM info WHERE UserName ='$u' AND Password ='$p' ";
$res = $conx->query($sql);
$row = ($res->fetch_array());
// num_rows count the rows fetched
if ($res->num_rows == 1) {
// Create Session
session_start();
$_SESSION["userId"] = $row['logid'];
$_SESSION["userNa"] = $row['UserName'];
if ($row['Status'] == 3) {
// Page for Doctor
$conx->close();
header('Location: doctor.php');
} elseif ($row['Status'] == 2){
// Page for Receptionist
$conx->close();
header('Location: receptionist.php');
} elseif ($row['Status'] == 1){
// Page for Patient
$conx->close();
header('location: patient.php');
} elseif ($row['Status'] == 0 ) {
// Page for Client
$conx->close();
header('Location:verify.php');
} } else {
$conx->close();
header('Location: denied.php');
}
?>
Try: header('Location: xyz.php', true, 301);
1 Like