dosterk Posted April 11, 2009 Share Posted April 11, 2009 I'm working on setting sessions to log people in using their username and password. I'm just having a problem getting the variables and the query to agree with one another. Here's what I have so far: <?phpsession_start();$dbc = @mysql_connect('localhost', 'studentx', 'xx') or die('Could not connect to MySQL: ' . mysql_error());mysql_select_db("student7", $dbc);$_SESSION['name']=$name;$_SESSION['password']=$password;$query="SELECT * FROM cusinfo WHERE email='$name' and password='$password'";$result=mysql_query($query);$count=mysql_num_rows($result);if($count==1){session_register("name");session_register("password"); header("location:index.php");}else {echo "Wrong Username or Password";}?> Where in the input field name for username on the sign in page is "name" and the password input name is "password". When I hard code a dummy email and password into that code, it works. So it must be a problem with it grabbing the text that is entered on the sign in page, correct? Thanks for the help guys, hopefully i'm missing something simple. Link to comment Share on other sites More sharing options...
zppblood Posted April 11, 2009 Share Posted April 11, 2009 Make sure you are assigning the variables for $name and $passwordhttp://us.php.net/manual/en/function.session-register.phpRead the warnings and notes. Link to comment Share on other sites More sharing options...
dosterk Posted April 11, 2009 Author Share Posted April 11, 2009 Make sure you are assigning the variables for $name and $passwordhttp://us.php.net/manual/en/function.session-register.phpRead the warnings and notes.Thanks, I got it working Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.