makka Posted May 1, 2007 Share Posted May 1, 2007 hello ive been making a basic login just to expand my knowledge a little this is my page that deals with my login but ive come to a hump in the bridge.. i get a error with this page <?php if (isset($_POST['submit'])) { include('config.php'); $query = "SELECT * FROM `users` WHERE username='".$_POST["username"]."' AND password='".md5($_POST["password"])."' LIMIT 1"; mysql_query($query) or die(mysql_error()); if (mysql_num_rows($query) != 1) { die("You have entered an invalid username or password."); } else { echo 'it worked'; } } ?> the error is Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\Program Files\xampp\htdocs\x\php+mysql\reg\login.php on line 6 so whats up here also what i don't get now is how do i know which user is which once they are logged in lets say i log in and its just a simply script that will redirect me to ball.php every time i click a this one link i will get one more number added to the msql db if i have a column called num in the db if you try to go to ball.php with out being logged in it will redirect you to the index page simple?? Link to comment https://forums.phpfreaks.com/topic/49429-need-some-help-with-a-log-in/ Share on other sites More sharing options...
xenophobia Posted May 1, 2007 Share Posted May 1, 2007 Wrong parameter had been sent... You should do this $sql = "SELECT ......."; $query = mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($query) != 1){ . . . } Link to comment https://forums.phpfreaks.com/topic/49429-need-some-help-with-a-log-in/#findComment-242259 Share on other sites More sharing options...
tauchai83 Posted May 1, 2007 Share Posted May 1, 2007 <?php if (isset($_POST['submit'])) { include('config.php'); $query = "SELECT * FROM `users` WHERE username='".$_POST["username"]."' AND password='".md5($_POST["password"])."' LIMIT 1"; $result=mysql_query($query) or die(mysql_error()); if (mysql_num_rows($result) < 1) { die("You have entered an invalid username or password."); } else { echo 'it worked'; } } ?> try this out. cheerss Link to comment https://forums.phpfreaks.com/topic/49429-need-some-help-with-a-log-in/#findComment-242261 Share on other sites More sharing options...
makka Posted May 1, 2007 Author Share Posted May 1, 2007 tauchai83 worked lovley now for my other question Link to comment https://forums.phpfreaks.com/topic/49429-need-some-help-with-a-log-in/#findComment-242267 Share on other sites More sharing options...
makka Posted May 1, 2007 Author Share Posted May 1, 2007 b 2 the u 2 the m 2 the p Link to comment https://forums.phpfreaks.com/topic/49429-need-some-help-with-a-log-in/#findComment-242654 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.