Vitamin Posted October 8, 2008 Share Posted October 8, 2008 I have a forum on one page and I'm passing though 2 variables. Username and Password. <?php $link = mysql_connect('localhost','root','password') or die("Failed Logon"); mysql_select_db("users"); $username = $_POST['username']; $password = $_POST['password']; if($username=="" || $password=="") { die("Please do not leave the username / password field blank!"); } $result = mysql_query("SELECT * FROM users WHERE username=$username AND password=$password"); $number = mysql_num_rows($result); if($number==0) { die("Your login details are not right. Please click the back button and correct them."); } echo $password ; echo $username ; ?> I know every thing works up to the point where it reaches the select statement then something is going wrong. I have all the correct information in the database and I've tried different users, but none are working. Any help would be appreciated. I'm new to php, but have done simular things with CF and Access. Quote Link to comment https://forums.phpfreaks.com/topic/127494-solved-user-log-on-form/ Share on other sites More sharing options...
Vitamin Posted October 8, 2008 Author Share Posted October 8, 2008 Sigh... got it. My database is not users thats my table username='$username' AND password='$password'"); And needed to add tick marks. Quote Link to comment https://forums.phpfreaks.com/topic/127494-solved-user-log-on-form/#findComment-659622 Share on other sites More sharing options...
mikelmao Posted October 8, 2008 Share Posted October 8, 2008 <?php $link = mysql_connect('localhost','root','password') or die("Failed Logon"); mysql_select_db("users"); $username = $_POST['username']; $password = $_POST['password']; if($username=="" || $password=="") { die("Please do not leave the username / password field blank!"); } $result = mysql_query("SELECT * FROM users WHERE username=". $username ." AND password=". $password"); $number = mysql_num_rows($result); if($number==0) { die("Your login details are not right. Please click the back button and correct them."); } echo $password ; echo $username ; ?> That should do it Quote Link to comment https://forums.phpfreaks.com/topic/127494-solved-user-log-on-form/#findComment-659774 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.