Jump to content

Php Session Help


monkeybidz

Recommended Posts

I am having trouble calling the  session var "email" from the landing page. Here is the code that I am using. I am not even sure the session "email" is starting or registering.

 

$referer = $_SERVER['HTTP_REFERER'];

$email = $_POST['email'];

$sql="SELECT * FROM users WHERE email='$email' ";
$result=mysql_query($sql);

// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $email, table row count must be 1 row

if($count==1){
// Session Register email
session_start();
  $_SESSION['email'] = $email;

header("location:".$referer2." ");
exit();
}

Link to comment
https://forums.phpfreaks.com/topic/255150-php-session-help/
Share on other sites

I am having trouble calling the  session var "email" from the landing page. Here is the code that I am using. I am not even sure the session "email" is starting or registering.

 

$referer = $_SERVER['HTTP_REFERER'];

$email = $_POST['email'];

$sql="SELECT * FROM users WHERE email='$email' ";
$result=mysql_query($sql);

// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $email, table row count must be 1 row

if($count==1){
// Session Register email
session_start();
  $_SESSION['email'] = $email;

header("location:".$referer2." ");
exit();
}

always have session_start() at the top of any page where you plan on using sessions, if session_start() is not there, sessions will not be displayed. Never have session start() in a condition.

Link to comment
https://forums.phpfreaks.com/topic/255150-php-session-help/#findComment-1308253
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.