Jump to content

Recommended Posts

Hi,

I made this mysql/md5 script... the problem is that it always returns there is an error logging in. I created the password hash with the same function..

$md5pass = md5($password);

Is there a different way to pull it out?

[code]<?php

$link = mysql_connect("localhost", "username", "password") or die(mysql_error());
mysql_select_db("database") or die(mysql_error());

$username = $_POST["username"];
$password = $_POST["password"];

$username = ereg_replace("[^A-Za-z0-9]", "", $username);
//$password = ereg_replace("[^A-Za-z0-9]", "", $password);

$md5pass = md5($password);

if (!empty($username) && ($password)) {

$sql = ("SELECT * FROM test WHERE username = '$username' AND password = '$md5pass'");
$result = mysql_query($sql);

if($result){
if(mysql_num_rows($result) > 0) {

echo "Welcome back $username";
    echo "!";
 
} else {
   
echo "There was an error logging in";
   
    }
}
    }
else {
  echo "Please enter your username and/or your password.";
}

mysql_close($link);

?> [/code]
Link to comment
https://forums.phpfreaks.com/topic/35301-mysqlmd5-whats-wrong/
Share on other sites

[quote author=KingPhilip link=topic=123589.msg511053#msg511053 date=1169519202]
Make sure you have it set for 32 characters in the db :)
[/quote]

Haha, sadly that worked  ::)

It was set for 20, because initially I wasn't going to encrypt the passwords.


Thanks!  ;D
Link to comment
https://forums.phpfreaks.com/topic/35301-mysqlmd5-whats-wrong/#findComment-166889
Share on other sites

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.