tritus Posted September 14, 2007 Share Posted September 14, 2007 heres whats happenin Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in on line 23 <?php $host = localhost; $dbuser = tritusco_jeff; $dbpass = ***********; $dbname = tritusco_users; $connection = mysql_connect($host, $dbuser, $dbpass); $db = mysql_select_db(prefix_dbname, $connection); $sql = "SELECT id FROM user WHERE email='$_POST' AND pass='$_POST[pass]'"; $result = mysql_query($sql); $num = mysql_num_rows($result); if ($num > 0) { //CHECK IF USER AND PASS ARE CORRECT $id = mysql_fetch_assoc($result); setcookie ("auth", "yes", time()+3600); setcookie ("id", $id['id']); setcookie ("email", $id['email']); header ("Location: main.php"); }else{ }; ?> Quote Link to comment https://forums.phpfreaks.com/topic/69264-ned-help-with-login-script/ Share on other sites More sharing options...
pocobueno1388 Posted September 14, 2007 Share Posted September 14, 2007 There is a problem with your query. Try to catch the error like this. $result = mysql_query($sql)or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/69264-ned-help-with-login-script/#findComment-348038 Share on other sites More sharing options...
tritus Posted September 14, 2007 Author Share Posted September 14, 2007 There is a problem with your query. Try to catch the error like this. $result = mysql_query($sql)or die(mysql_error()); fixed it but it wont select the user from database and log in... i have it so it encryptys the password when they sign up would that have ne thing to do with it? Quote Link to comment https://forums.phpfreaks.com/topic/69264-ned-help-with-login-script/#findComment-348041 Share on other sites More sharing options...
teng84 Posted September 14, 2007 Share Posted September 14, 2007 show the code that encrypt user pass ! Quote Link to comment https://forums.phpfreaks.com/topic/69264-ned-help-with-login-script/#findComment-348046 Share on other sites More sharing options...
tritus Posted September 14, 2007 Author Share Posted September 14, 2007 show the code that encrypt user pass ! its in $sql <?php $host = localhost; $dbuser = tritusco_jeff; $dbpass = '*****'; $dbname = tritusco_users; $dbconn = mysql_connect($host, $dbuser, $dbpass); if (!$dbconn) { exit('<p>Unable to connect to the' . 'databse server at this time.</p>'); } else { } if (!mysql_select_db($dbname)) { exit('<p>Unable to locate the users '. 'database at this time</p>'); } $db = mysql_select_db($dbname, $dbconn); //grab data from form $fname = $_POST['fname']; $lname = $_POST['lname']; $email = $_POST['email']; $pass = $_POST['pass']; $passconf = $_POST['passconf']; //if else (else if) if($fname == false || $lname == false || $email == false || $pass == false){ echo "Please fill in all fields."; }; if($pass != $passconf){ echo "Passwords do not match."; }else { $db = mysql_select_db($dbname, $dbconn); $sql = "INSERT INTO user (date, time, fname, lname, email, pass, level) VALUES (CURDATE(), CURTIME(), '$fname', '$lname', '$email', ENCRYPT('$pass'), 'u')"; }; if (mysql_query($sql)) { echo '<p>Thanks for registering on CollegeBookTrade.com</p>'; } else { echo mysql_error (); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/69264-ned-help-with-login-script/#findComment-348052 Share on other sites More sharing options...
teng84 Posted September 14, 2007 Share Posted September 14, 2007 $sql = "SELECT id FROM user WHERE email='$_POST[email]' AND pass='".ENCRYPT($_POST[pass])."'"; on your login page it should look like something like this Quote Link to comment https://forums.phpfreaks.com/topic/69264-ned-help-with-login-script/#findComment-348061 Share on other sites More sharing options...
tritus Posted September 14, 2007 Author Share Posted September 14, 2007 $sql = "SELECT id FROM user WHERE email='$_POST[email]' AND pass='".ENCRYPT($_POST[pass])."'"; on your login page it should look like something like this not working:-\ Quote Link to comment https://forums.phpfreaks.com/topic/69264-ned-help-with-login-script/#findComment-348067 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.