Jump to content

Recommended Posts

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");
}
?>

Link to comment
https://forums.phpfreaks.com/topic/107084-login-verification-problem/
Share on other sites

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

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");
}
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.