Jump to content

why doesnt this work.. setting sessions...


Recommended Posts

page 1 is this

session_start();
include 'db.php';

$email = $_POST['email'];
$password = $_POST['password'];

$email = stripslashes($email);
$password = stripslashes($password);
$email = mysql_real_escape_string($email);
$password = mysql_real_escape_string($password);	

$sql="SELECT * FROM directory WHERE email='$email' and password='$password' ";
$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){

$wtf="SELECT * FROM directory WHERE email='$email' and password='$password' ";
while($row = mysql_fetch_array($wtf))
  {
	$fname = $row['fname'];
	$lname = $row['lname'];
	$address = $row['address1'];
	$city = $row['city'];
	$state = $row['state'];
	$zip = $row['zip'];
  }
  
$_SESSION['user'] = $email;
$_SESSION['fname'] = $fname;
$_SESSION['lname'] = $lname;
$_SESSION['address1'] = $address;
$_SESSION['city'] = $city;
$_SESSION['state'] = $state;
$_SESSION['zip'] = $zip;
$_SESSION['status'] = "1";

 

page two is just: only the user and status works.

session_start();

echo $_SESSION['user'] ;
echo $_SESSION['fname'] ;
echo $_SESSION['lname'] ;
echo $_SESSION['address1'];
echo $_SESSION['city'] ;
echo $_SESSION['state'] ;
echo $_SESSION['zip'];
echo $_SESSION['status'];

 

why is that not working

 

Link to comment
https://forums.phpfreaks.com/topic/218499-why-doesnt-this-work-setting-sessions/
Share on other sites

Haha, yes, that would do it.  You don't actually run the query.

 

Also, a debugging tip:  Read your post and your first response.  You are saying "here is a script that's designed to store some database data in the session.  The only thing being stored is the data from outside the database loop.  What is the problem?  The problem, clearly, is the database loop. 

 

Turn error_reporting all the way up, you would have gotten an error from the mysql_fetch_array line.

 

Echo what you think might be a problem.  if you had put an echo inside that loop, you would have known beforehand that it wasn't running.

 

-Dan

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.