Jump to content

Recommended Posts

Good afternoon all, I am currently using md5 on my password field for my login processor, but I know I can secure this better. I was given advice the other day to use a hash, but I am not quite sure how to do it. Here is a relevant snippet from my code, I am open to all suggestions! :) Thanks!

 

//
//User Login
//
session_start();

$username = $_POST['username']; //Username
$password = md5($_POST['password']); //Password

$query = "SELECT * FROM users WHERE username='" .
mysql_real_escape_string($username) .
"' AND password='$password'";
$result = mysql_query($query);

if (mysql_num_rows($result) != 1) {
$error = "Invalid login, Please check your credentials and try again";
include "login.html";
} else {
$_SESSION['username'] = $username;
include "main_interface.php";
}
?>

Edited by trg86
Link to comment
https://forums.phpfreaks.com/topic/270041-securing-my-password-field-better/
Share on other sites

I wouldn't use md5 as it is easily broken through look up tables. I think todays standards are sha1 or better, some even going to crypt. Whatever you decide, use a salt. Very important.

 

Yeah, I was actually just doing some research on this, it looks like a Sha1/Salt setup is the way to go.

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.