在数据库中设置 md5 加密,然后在 login.php 中我使用 select 语句进行匹配:
<?php
session_start();
include"db.php";
if ( isset( $_POST['email_id'] ) ) {
$email_id = $_POST['email_id'];
$password = $_POST['password'];
$sql="SELECT * FROM user WHERE email_id='$email_id' AND password='md5($password)' LIMIT 1";
$res = mysql_query($sql);
$count = mysql_num_rows($res);
if ( $count == "1" ) {
$row = mysql_fetch_array($res);
$name = $row["first_name"];
$_SESSION["name"] = $name;
$_SESSION["password"] = $password;
header("location:index.php");
exit();
} else {
echo "Invalid LOGIN information.";
exit();
}
}
?>
将显示消息“无效的登录信息”。