Does not work header location in webhost ? when i try in local host its work

<?php
ob_start();
if(isset($_POST['saves'])){
$username = $_POST['name'];$password = $_POST['pwd'];
if($username ==='fffff' && $password ==='crscrs'){
$_SESSION['login'] = 1; (header('LOCATION: irs.php'));
 die();
} 
{
echo"<div class='alert alert-danger'>INVALID DETALIS</div>";
}}
ob_end_flush();
?>

You should add session_start(); to the beginning of your code

yes i’m add session_start(); but not work plz help me

Hi @chitti can you try this code

 <?php
ob_start();
if(isset($_POST['saves'])){
$username = $_POST['name'];$password = $_POST['pwd'];
if($username ==='fffff' && $password ==='crscrs'){
$_SESSION['login'] = 1; (header('Location: irs.php'));
 die();
} 
{
echo"<div class='alert alert-danger'>INVALID DETALIS</div>";
}}
ob_end_flush();
?>

NO sorry not work hepl me

Try this one

<?php
session_start();
if(isset($_POST['saves'])){
$username = $_POST['name'];
$password = $_POST['pwd'];
if($username ==='fffff' && $password ==='crscrs'){
$_SESSION['login'] = 1;
header('Location: irs.php');
 exit();
}else{
echo"<div class='alert alert-danger'>INVALID DETALIS</div>";
}
}
?>

ok its work thanksto all

1 Like