session_start();
$_SESSION['fname']=$row['fname'];
$_SESSION['user']=$row['name'];
$_SESSION['adpoint'] = $row['adpoint'];
$_SESSION['phone']=$row['phone'];
$_SESSION['id'] = $row['id'];
$_SESSION['rememberMe'] = $_POST['rememberMe'];
// Store some data in the session
setcookie('smsapp',$_POST['rememberMe']);
echo "your name"." ".$_SESSION['user'];
Print_r ($_SESSION);
header("Location: http://www.niktrixhosting.com/login/user/index.php");
here in this code header("Location: http://www.niktrixhosting.com/login/user/index.php"); this line is not redirecting it
plz mentionif any another function for redirecting page .
try
echo "<script>window.location=\"http://www.niktrixhosting.com/login/user/index.php\"</script>";
instead of:
header("Location: http://www.niktrixhosting.com/login/user/index.php");
You're trying to set the headers after sending them. Comment out the echo "your name"." ".$_SESSION['user'];
line and everything will work.
Explanation: The headers are always the first thing sent (that's why they're called headers). When you call echo
, part of the page is sent, but if the headers aren't set, they will be sent first. What's happening in your code is that the echo
line is sending the headers, and then you're trying to set them after the headers have already been sent (which doesn't work).
You can't echo
and print_r
or give any other output before function header
.
Headers should be sent before any output, so any statement with an echo
or a print_r
before a header will cause errors.
you are not to echo/print out/output anything before using header(). that will really affect your PHP page.