iJoseph Posted May 5, 2010 Share Posted May 5, 2010 I have made some code to log into a website. However, when the code runs there appears to be no output. Here is the code: <?php $username = $_POST['reg_username']; $password = $_POST['reg_password']; include "database.php"; $row = mysql_query("SELECT * FROM users WHERE username='$username' && password='$password'"); while($relult = mysql_fetch_array($row)) { if($username == $result['username']){ echo "Logged in."; } else { echo "Not logged in."; } } ?> When the file runs, the page is blank. I have not been programming with PHP very long (I'm only 13) and I would like it if sombody could help me, Thanks Quote Link to comment https://forums.phpfreaks.com/topic/200816-php-login-help/ Share on other sites More sharing options...
Muddy_Funster Posted May 5, 2010 Share Posted May 5, 2010 Try for somthing like this: <?php $username = $_POST['reg_username']; $password = $_POST['reg_password']; include "database.php"; $result = mysql_query("SELECT username, password FROM users WHERE username='".$username."' AND password= '".$password."'") or die (mysql_error()); $row = mysql_fetch_assoc($rersult) if($username == $row['username'] && $password == $row['password']){ echo "Logged in."; } else { echo "Not logged in."; } ?> The reason that you are getting a blank screen is because you don't have error reporting set up properly on the server. Quote Link to comment https://forums.phpfreaks.com/topic/200816-php-login-help/#findComment-1053682 Share on other sites More sharing options...
Pikachu2000 Posted May 5, 2010 Share Posted May 5, 2010 You've misspelled "result" as "relult" in the while() . . . Quote Link to comment https://forums.phpfreaks.com/topic/200816-php-login-help/#findComment-1053688 Share on other sites More sharing options...
iJoseph Posted May 5, 2010 Author Share Posted May 5, 2010 Thanks Both of you I can't beleve I missed the $relult. Quote Link to comment https://forums.phpfreaks.com/topic/200816-php-login-help/#findComment-1053710 Share on other sites More sharing options...
Pikachu2000 Posted May 5, 2010 Share Posted May 5, 2010 At least it wasn't relulz . . . Quote Link to comment https://forums.phpfreaks.com/topic/200816-php-login-help/#findComment-1053716 Share on other sites More sharing options...
Muddy_Funster Posted May 5, 2010 Share Posted May 5, 2010 ...or "rersult" Quote Link to comment https://forums.phpfreaks.com/topic/200816-php-login-help/#findComment-1053722 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.