Hello,
I have a login script that I created and for some weird reason when it is in plaintext it works, but as soon as I put md5() it errors out and will not let me log in at all.
<?php
session_start();
error_reporting(E_ALL);
ini_set("display_errors", 1);
include("config.php");
if($_SERVER["REQUEST_METHOD"] == "POST")
{
$errmsg = '';
// username and password sent from Form
$username=$_POST['username'];
$password=$_POST['password'];
// To protect MySQL injection
$username = mysql_real_escape_string($username);
$password = mysql_real_escape_string($password);
$md5pass = md5($password);
if( $username == ''){
$errmsg = 'Error: Please enter your username';
}else{
if($md5pass == ''){
$errmsg = 'Error: Please enter your password';
}else{
$sql="SELECT id FROM admin WHERE username='$username' and passcode= ' $md5pass '";
$result=mysql_query($sql);
$row=mysql_fetch_array($result);
$count=mysql_num_rows($result);
// If result matched $username and $md5pass, table row must be 1 row
if($count==1)
{
session_register("username");
$_SESSION['login_user']=$username;
header("location: index.php");
}
else
{
$errmsg = "Error: your Username or Password is invalid. <br /> If you haven't registered yet, you can <a href='register.php'>register here</a>";
}
}
}
}
?>
The only error I am getting is from the login code when you come back with an error is when there is no errors at all.