- Impact
- 11
I cant seem to get the data to display from the session, the code im using is below.
The header file contains the session_start(); and db information.
Heres my full login.php:
And heres a page where I want to show data from the session: (I tried with echo's to, but still didnt work)
My next problem is that the session_destroy() isnt working... heres the code
The header file contains the session_start(); and db information.
Heres my full login.php:
PHP:
<? include'inc/header.php'; ?>
<div id="home">
<b>Please Login</b>
<hr noshade>
<p>
<center>
<? if(session_id()!=''){
echo'Your already logged in.';
}else{
?>
<?
if($_GET['i'] == "2") {
$email = stripslashes($_POST['email']);
$password = md5(stripslashes($_POST['password']));
$sql = mysql_query("SELECT * FROM members WHERE email='$email' AND password='$password'");
$login_check = mysql_num_rows($sql);
if($login_check > 0){
while($row = mysql_fetch_array($sql)){
$_SESSION['fullname'] = $row['fullname'];
$_SESSION['address1'] = $row['address1'];
$_SESSION['address2'] = $row['address2'];
$_SESSION['city'] = $row['city'];
$_SESSION['state'] = $row['state'];
$_SESSION['country'] = $row['country'];
$_SESSION['email'] = $row['email'];
$_SESSION['paypal'] = $row['paypal'];
$_SESSION['offers'] = $row['offers'];
$_SESSION['completedoffers'] = $row['completedoffers'];
$_SESSION['pendingoffers'] = $row['pendingoffers'];
$_SESSION['pendingbalance'] = $row['pendingbalance'];
$_SESSION['balance'] = $row['balance'];
mysql_query("UPDATE members SET lastlogin=now() WHERE email='$email'");
echo'Login Successful';
}
}else{
echo 'The information you entered is not correct.';
}
}else{
?>
<form action="login.php?i=2" method="POST">
Email<br /> <input size="20" type="text" name="email" class="signup"> <br />
Password<br /> <input size="15" type="password" name="password" class="signup"> <br /><br />
<input type="submit" value="Login">
</form>
<?
}
}
?>
</center>
</p>
</div>
<? include'inc/footer.php'; ?>
And heres a page where I want to show data from the session: (I tried with echo's to, but still didnt work)
PHP:
<? include'inc/header.php'; ?>
<div id="home">
<? if(session_id()!=''){ ?>
<? include'inc/menu.php'; ?><br />
<hr noshade>
<br />
Full Name: <? $_SESSION['fullname']; ?> <br />
Address 1: <? $_SESSION['address1']; ?> <br />
Address 2: <? $_SESSION['address2']; ?><br />
City: <? $_SESSION['city']; ?><br />
State: <? $_SESSION['state']; ?><br />
Country: <? $_SESSION['country']; ?><br />
Zip Code: <? $_SESSION['zip']; ?><br /> <br />
<br />
<input type="submit" value="Change">
<?
}else{
echo'Your Not Logged In.';
}
?>
</div>
<? include'inc/footer.php'; ?>
My next problem is that the session_destroy() isnt working... heres the code
PHP:
<? include'inc/header.php'; ?>
<div id="home">
<b>Logging Out</b>
<hr noshade>
<p>
<center>
<? if(session_id()!=''){
session_destroy();
?>
You have been logged out.
<?
}else{
?>
Your not logged in.
<?
}
?>
</center>
</p>
</div>
<? include'inc/footer.php'; ?>






