我是否正确地做到了?使用标题("位置:....")重定向到另一个页面?
你能否建议改进代码,因为我对这件事情不熟悉......
<?php
require 'db.php';
$msg='';
if(!empty($_POST['username']) && isset($_POST['username']) && !empty($_POST['password']) && isset($_POST['password']))
{
$username = mysqli_real_escape_string($connection, $_POST['username']);
$password = mysqli_real_escape_string($connection, $_POST['password']);
$sql = mysqli_query($connection, "SELECT username FROM admin WHERE username = '".$username."' AND password ='".$password."'");
$count = mysqli_num_rows($sql);
if($count == 1)
{
header("Location: AdminDeleteAccount.php");
exit;
}
else
{
$msg='Username and Password didnt match';
}
mysqli_close($connection);
}
else
{
echo 'howdie';
}
?>
答案 0 :(得分:0)
是的,你正确地做到了,使用某种加密方式将密码存储在数据库中,如MD5,sh1等。还要确保在header
函数或标题{{1}之前没有任何内容被回显}将无法工作,您将看到一条错误消息。