guarinnd Posted May 24, 2008 Share Posted May 24, 2008 Hello. I have recently been working on a php script to verify that the login information is correct, and redirect them to a seperate page depending on the result. I seem to have come across a problem. I keep getting redirected to the failed login page, even if I enter correct information. If anybody has time, could you please explain to me what I am doing wrong? The Source code is listed below. Thank you in advance. <?php $passhash = md5($_post["password"] + "1a2b"); $usrnm = $_post["username"]; $usrnm = @strip_tags(stripslashes($login)); @mysql_connect("localhost","tgschr_verify","123") or die("Cannot Connect to MYSql Database"); @mysql_select_db("tgschr_login"); $sql = "SELECT member_id FROM Users WHERE Username='.$usrnm' AND Password='.$passhash' LIMIT 1"; $r = mysql_query($sql); if (!$r) { session_start(); $_session['member_id'] = "'$sql'"; header("Location: http://www.-deleted url-.com/members/index.htm"); } else { header("Location: http://www.-deleted url-.com/failed_login.html"); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/107084-login-verification-problem/ Share on other sites More sharing options...
.josh Posted May 24, 2008 Share Posted May 24, 2008 First thing I notice is $usrnm = $_post["username"]; $usrnm = @strip_tags(stripslashes($login)); perhaps you meant to put $usrnm instead of $login? If that doesn't do it, then lemme know. Quote Link to comment https://forums.phpfreaks.com/topic/107084-login-verification-problem/#findComment-548975 Share on other sites More sharing options...
guarinnd Posted May 24, 2008 Author Share Posted May 24, 2008 Thank you for that. It did not do anything for my problem, but it should help in the future. I have also removed the salt at the end of the md5 conversion, and adjusted the MYSql table accordingly, but that still did not help. Edit: Almost forgot. If you need more information, go to http://www.abnormalstatic.com/info.php Quote Link to comment https://forums.phpfreaks.com/topic/107084-login-verification-problem/#findComment-548981 Share on other sites More sharing options...
jonsjava Posted May 24, 2008 Share Posted May 24, 2008 This code should work (with the MD5 and salted): <?php $passhash = md5($_post["password"]."1a2b"); $usrnm = $_post["username"]; $usrnm = @strip_tags(stripslashes($usrnm)); @mysql_connect("localhost","tgschr_verify","123") or die("Cannot Connect to MYSql Database"); @mysql_select_db("tgschr_login"); $sql = "SELECT member_id FROM Users WHERE Username='.$usrnm' AND Password='.$passhash' LIMIT 1"; $r = mysql_query($sql); if (!$r) { session_start(); $_session['member_id'] = "'$sql'"; header("Location: http://www.-deleted url-.com/members/index.htm"); } else { header("Location: http://www.-deleted url-.com/failed_login.html"); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/107084-login-verification-problem/#findComment-549002 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.