When I tried this code:
when i run my loginPHP Code:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<p>
<label for="username">Username: </label>
<input type="text" name="username" id="username" />
</p>
<p>
<label for="password">Password: </label>
<input type="password" name="password" id="password" />
</p>
<p>
<input type="submit" name="submit" id="submit" value="Submit" />
</p>
<?php
include 'connection.php';
if (isset($_POST['submit'])) {
$username=$_POST['username'];
$password=$_POST['password'];
// encrypt password
$encrypted_mypassword=md5($password);
$sql="SELECT * FROM tbllogin WHERE username='$username' and password='$encrypted_mypassword'";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
if($count==1){
header("location:machine1.php");
}
else {
echo "Wrong Username or Password";
}
}
//$username = mysql_real_escape_string($username);
//$password = mysql_real_escape_string($password);
//$password = mysql_real_escape_string(sha1($password));
//$sql="UPDATE `tbllogin` SET `password` = SHA1(`password`) WHERE username = $username";
//$sql="UPDATE tbllogin SET password = MD5('password') WHERE username = '$username'";
//$result=mysql_query($sql);
//mysql_query("UPDATE tbllogin SET password = '$password' WHERE username = '$username'");
//$sql = "SELECT * FROM tbllogin WHERE username='$username' and password='" . md5($password) . "'";
//$sql="SELECT * FROM tbllogin WHERE username='$username' and password='$password'";
//$hashed_pass = md5($password);
//$sql="SELECT * FROM tbllogin WHERE username='$username' and password='$hashed_pass'";
//$result=mysql_query($sql);
?>
</form>
</body>
</html>
the wrong username or password was display even though I am inputting anything in username and password and also when i input username and password still wrong username or password.
:crying:
I really don't know how can I fix my problem in encrypting password and login successfully.
Thank you for your help

