Page 1 of 1

$_SESSION[] not getting value

Posted: Wed Dec 09, 2009 6:30 am
by Sam2010
How do I do, to get values while using $_SESSION. I'am unable to get any values?

Re: $_SESSION[] not getting value

Posted: Wed Dec 09, 2009 6:33 am
by Grizzzzzzzzzz
what's your current code that isn't working

Re: $_SESSION[] not getting value

Posted: Wed Dec 09, 2009 6:58 am
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>";

Re: $_SESSION[] not getting value

Posted: Wed Dec 09, 2009 7:02 am
by jackpf
Turn on error reporting?

Re: $_SESSION[] not getting value

Posted: Wed Dec 09, 2009 7:30 am
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.

Re: $_SESSION[] not getting value

Posted: Wed Dec 09, 2009 11:13 pm
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.