creet0n Posted May 15, 2007 Share Posted May 15, 2007 Whenever I run this script, it comes back and says the username/password is incorrect even though I set it up in database already. I can't find what's wrong, so can someone look at it for me? <?php if($_POST['submitted'] != '1') { ?> <form action="<?php $_SERVER['PHP_SELF']; ?>" method="POST"> <input type="text" name="myusername"><br> <input type="password" name="mypassword"><br> <input type="hidden" name="submitted" value="1"><br> <input type="submit" name="submit" value="submit"> </form> <?php }else{ $host = "s*******"; $username = "p*******"; //PUT IN USERNAME!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! $password = "r*******"; //PUT IN PASSWORD!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! $db_name="p*******"; //PUT IN DBNAME!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! $tbl_name="members"; mysql_connect("$host", "$username", "$password") or die("cannot connect..."); mysql_select_db("$db_name") or die("cannot select DB..."); $myusername = $_POST['myusername']; $mypassword = $_POST['mypassword']; $sql = "SELECT * FROM $tbl_name WHERE username = '$myusername' AND password = '$mypassword'"; $result = mysql_query($sql); $cound = mysql_num_rows($result); if($count == 1) { session_register("myusername"); session_register("mypassword"); header("location:index.php"); //FILL WITH WHATEVER } else { echo "Wrong Username or Password"; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/51565-solved-uhh-in-testing-something-new-this-didnt-work-help/ Share on other sites More sharing options...
creet0n Posted May 15, 2007 Author Share Posted May 15, 2007 NOTE: Please disregard those comments "PUT IN _____" I forgot to remove them. Quote Link to comment https://forums.phpfreaks.com/topic/51565-solved-uhh-in-testing-something-new-this-didnt-work-help/#findComment-253937 Share on other sites More sharing options...
Gobbo Posted May 16, 2007 Share Posted May 16, 2007 Well, the first thing I noticed was this: <?php $cound = mysql_num_rows($result); if($count == 1) {... ?> You set the variable as 'cound' and then call 'count'. Quote Link to comment https://forums.phpfreaks.com/topic/51565-solved-uhh-in-testing-something-new-this-didnt-work-help/#findComment-254053 Share on other sites More sharing options...
creet0n Posted May 16, 2007 Author Share Posted May 16, 2007 haha yes i just realized that. thank you! ok, it works fine now i feel like a loser :'( Quote Link to comment https://forums.phpfreaks.com/topic/51565-solved-uhh-in-testing-something-new-this-didnt-work-help/#findComment-254819 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.