darkenedember Posted September 28, 2008 Share Posted September 28, 2008 Hello. I am currently making a login panel for my site, but I cannot seem to get a script to work. I have, with a bit of testing, found the location of the error, but cannot understand what it is. <?php require('config.php'); mysql_connect($config['dbhost'],$config['dbuser'],$config['dbpass']); @mysql_select_db($config['dbname']) or die("could not connect"); $username = $_POST['username']; $password = $_POST['password']; $hash1 = md5($password); $hash2 = sha1($hash1); $table = $config['dbprefix'] . "adminlogin"; $query = "SELECT password FROM " . $table . "WHERE username=" . $username; $result = mysql_query($query); if ($result == $hash2) { $cookievalue = [color=red]<deleted value>[/color]; setcookie("asadmin", $cookievalue, time()+3600); header('Location: [color=red]<url deleted>[/color]'); } elseif ($result == NULL) { echo "null"; } else { die("INVALID PASSWORD"); } ?> I have, with the inclusion of that elseif, found that the query will not return a value. Could somebody please point out what I am doing wrong? Thank you, and I am sorry if this is in the wrong section. Link to comment https://forums.phpfreaks.com/topic/126134-solved-problem-with-verification-script/ Share on other sites More sharing options...
ratcateme Posted September 28, 2008 Share Posted September 28, 2008 you need a space before the WHERE try adding "or die(mysql_error());" after your query Scott. Link to comment https://forums.phpfreaks.com/topic/126134-solved-problem-with-verification-script/#findComment-652223 Share on other sites More sharing options...
F1Fan Posted September 28, 2008 Share Posted September 28, 2008 Also, you should have single quotes around the username variable in the query if it's text. Link to comment https://forums.phpfreaks.com/topic/126134-solved-problem-with-verification-script/#findComment-652449 Share on other sites More sharing options...
darkenedember Posted September 29, 2008 Author Share Posted September 29, 2008 Thank you both for the help. The double quotes thing helped alot, and so did the mysql_error() function. Link to comment https://forums.phpfreaks.com/topic/126134-solved-problem-with-verification-script/#findComment-652623 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.