<?php
include("connect.php");
session_start();
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Username and password sent from form in HTML
$myusername = $_POST['username'];
$mypassword = $_POST['password'];
$sql = "SELECT id FROM users WHERE username='$myusername' and password='$mypassword'";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
$active = $row['active'];
$count = mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if ($count == 1) {
session_register("myusername");
$_SESSION['login_user'] = $myusername;
header("location: welcome.php");
} else {
$error = "Your username or password is invalid";
}
}
?>
这是我当前的登录代码。在我的注册页面上,我有它,因此当它注入数据库时,它会注入已经在 MD5 中加密的密码。但是,我似乎无法转换:
$mypassword=$_POST['password'];
进入MD5确认,看看密码是否存在于数据库中。使用此代码,不得加密密码。我应该改变什么来使它检查加密的数据库?