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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.