Jump to content

[SOLVED] Session trouble


master82

Recommended Posts

I have the following simple login authentication script...

 

<?php
session_start();
include "database.php";
if ($_POST['email'] == "" || $_POST['password'] == "")
{
die("You did not fill in the login form!<br>
<a href=login.php>-Back-</a>");
}
$mc=mysql_query("SELECT mid FROM members WHERE memail='{$_POST['email']}' AND mpassword=md5('{$_POST['password']}')");
if(mysql_num_rows($mc)!=1)
{
die("Invalid email or password!<br>
<a href=login.php>-Back-</a>");
}
else
{
$_SESSION['log']=1;
$m=mysql_fetch_row($mc);
$_SESSION['member']=$m['mid'];
$IP = ($_SERVER['HTTP_X_FORWARDED_FOR'])
    ?  $_SERVER['HTTP_X_FORWARDED_FOR']
    :  $_SERVER['REMOTE_ADDR'];
mysql_query("UPDATE members SET mlastip='$IP',mlaston=unix_timestamp() WHERE mid={$m['mid']}");
}
//header("Location: index.php");
print"LS - {$_SESSION['log']}<p>MS - {$_SESSION['member']}<p>Mid - {$m['mid']}";
?>

 

However I did not seem to carry the session information over, so I removed the redirect and printed the values instead:

 

Session - log = 1

Session - member = *blank*

$m['mid'] = *blank*

 

Anyone help?

Link to comment
https://forums.phpfreaks.com/topic/39415-solved-session-trouble/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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