reddavis999 Posted May 10, 2007 Share Posted May 10, 2007 hey everyone. Ive recently started learning PHP and have made a simple login script for my project for college. The problem i am having is that the session does not seem to be carried from page to page. The session variable is called $_session["logged"] Here is the code where the username and password is checked... <?php session_start(); include ("name.inc"); //connect to DB mysql_connect ("$host","$username","$password") or die ("couldnt connect"); mysql_select_db ("$database") or die ("cannot select database"); //Information sent from the form $myusername = $_POST['username']; $mypassword = $_POST['password']; $result = mysql_query("SELECT * FROM $table where username='$myusername' and password='$mypassword'"); //gets number of rows with query above $count = mysql_num_rows($result); //if the results matched then the number of rows will be 1... if($count == 1){ $_session['logged'] = "hello"; header("location:session.php"); } else { echo "wrong username and password"; } ?> And here is a file i made to check whether the information is being carried forward... <?php session_start(); echo $_session["logged"]; ?> Here is the website if you would like to see the problem. jobchaser.info username:admin password:password or username:john password:red Thanks for your help, Red Link to comment https://forums.phpfreaks.com/topic/50818-solvedsession/ Share on other sites More sharing options...
trq Posted May 10, 2007 Share Posted May 10, 2007 It needs to be $_SESSION not $_session. Link to comment https://forums.phpfreaks.com/topic/50818-solvedsession/#findComment-249876 Share on other sites More sharing options...
reddavis999 Posted May 10, 2007 Author Share Posted May 10, 2007 It needs to be $_SESSION not $_session. wow! what a quick reply, and thanks so much:) Isn't is annoying how it always the little things. cheers, Red Link to comment https://forums.phpfreaks.com/topic/50818-solvedsession/#findComment-249882 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.