我在我的网站上设置了注册系统,当用户注册时,密码是他们注册时使用的电子邮件和密码的 md5 混合。不幸的是,我无法让它正常工作。这是代码:
注册时:
$user = strip_tags(substr($_POST['email'],0,32));
$pass = strip_tags(substr($_POST['password'],0,32));
$cleanPass = crypt(md5($pass),md5($user));
$date = time();
$stmt = $db->prepare("INSERT INTO users (password, email, first, last, date)
VALUES(:password, :email, :first, :last, :date)");
登录时:
$email = $_POST['email'];
$user = strip_tags(substr($_POST['email'],0,32));
$pass = strip_tags(substr($_POST['password'],0,32));
$cleanPass = crypt(md5($pass),md5($user));
$stmt = $db->prepare("SELECT email,password FROM users WHERE email=:email AND password=:password limit 1");