I know, header() must be called before any actual output is sent. But I am trying to use header() to include session in my xammp server. The code is:
$member_id=$_REQUEST['member_id'];
$member_id = stripslashes($member_id);
$sql="SELECT * FROM member WHERE member_id='$member_id'";
$result=mysql_query($sql);
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){
$_SESSION['member_id']=$member_id;
header("location:index.php?page=member_account&&member=success");
}
this above code is working well in my Localhost. But when I upload this script on online server then server shows a warning that looks like this: Warning: Cannot modify header information - headers already sent by (output started at /home/emonuniq/public_html/index.php:16) in /home/emonuniq/public_html/inc/member/check.php on line 15. Then I try another way to redirect this LINK on javascript.
//script tag is not showing
echo("location.href = 'index.php?page=member_account&&member=success';
");
this code redirect successfully on success.php. But in this page session doesn't work. How can I do?