$_SESSION[] not getting value

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Sam2010
Forum Newbie
Posts: 4
Joined: Wed Dec 09, 2009 6:25 am

$_SESSION[] not getting value

Post by Sam2010 »

How do I do, to get values while using $_SESSION. I'am unable to get any values?
Last edited by Sam2010 on Wed Dec 09, 2009 6:59 am, edited 2 times in total.
User avatar
Grizzzzzzzzzz
Forum Contributor
Posts: 125
Joined: Wed Sep 02, 2009 8:51 am

Re: $_SESSION[] not getting value

Post by Grizzzzzzzzzz »

what's your current code that isn't working
Sam2010
Forum Newbie
Posts: 4
Joined: Wed Dec 09, 2009 6:25 am

Re: $_SESSION[] not getting value

Post by Sam2010 »

else {
session_start();
$_SESSION['login'] = $login;

echo 'Logged';

}

What will be the script to add, if I looking for the phone and the email?


echo "<b>Phone:</b> ".$_SESSION['phone']."<br>";

echo "<b>Email:</b> ".$_SESSION['email']."<br>";
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: $_SESSION[] not getting value

Post by jackpf »

Turn on error reporting?
Sam2010
Forum Newbie
Posts: 4
Joined: Wed Dec 09, 2009 6:25 am

Re: $_SESSION[] not getting value

Post by Sam2010 »

pickle | Please use [ code=php ], [ code=text ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: Posting Code in the Forums to learn how to do it too.


Here is the complet script:

Code: Select all

<?php
 
if(isset($_POST) && !empty($_POST['login']) && !empty($_POST['pass'])) {
  extract($_POST);
 
 
  $sql = "select pwd from tbl_user2 where login='".$login."'";
  $req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
 
  $data = mysql_fetch_assoc($req);
 
  if($data['pwd'] != $pass) {
    echo '<p>Mauvais login / password. Merci de recommencer</p>';
    include('login.htm'); // On inclut le formulaire d'identification
    exit;
  }
  else {
    else {
    session_start();
    $_SESSION['login'] = $login;
 
    echo 'Logged';
 
   echo "<b>Login</b> ".$_SESSION['login']."<br>";
   echo "<b>Phone:</b> ".$_SESSION['phone']."<br>";
   echo "<b>Email:</b> ".$_SESSION['email']."<br>";
  }   
}
else {
  echo '<p>Vous avez oublié de remplir un champ.</p>';
   include('login.htm'); // On inclut le formulaire d'identification
   exit;
}
 
 
?>

pickle | Please use [ code=php ], [ code=text ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: Posting Code in the Forums to learn how to do it too.
Sam2010
Forum Newbie
Posts: 4
Joined: Wed Dec 09, 2009 6:25 am

Re: $_SESSION[] not getting value

Post by Sam2010 »

Ok, I will next time.

I just start in PHP. It maybe simple but I really need help with this script.

I've tried lots of things but nothing working.

Thanks.
Post Reply