0

i am trying to register 2 sessions. one is supposed to get the id of the user logging in, the other is supposed to get the persons username. here is the login page:

<?php
session_start();
include "dbconnect.php";

$myusername=$_POST['user'];
$mypassword=$_POST['pass'];

$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);

$sql="SELECT * FROM $tbl_name WHERE email='$myusername' AND password='$mypassword'";
$resID=mysql_query($sql);

$count=mysql_num_rows($resID);

if($count==1){
$result = mysql_fetch_assoc ($resID);

$_SESSION['myusername'] = $result['username'];
$_SESSION['uid'] = $result['id'];
header('location:memberspage.php');
}
else {
echo "Wrong Username or Password";
}
?>

and the members.php page:

<?php
session_start();
include "dbconnect.php";
$id = $_SESSION['uid'];
$username = $_SESSION['myusername'];
?>

the sessions are not registering and will not work.
if anybody could please help that would be awesome

3
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by kohyar bolvary
0

when you start a session be careful because it my not be closed in it is still open.
you have two session at the start of each code so you have to kill the actions of both.
use this in a new php tag
$_session(die);
so you are directly omitting the affect of each action

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.