Admin Login 我在php上制作了method="POST"表单 if ($_SERVER['REQUEST_ME-6ren">
gpt4 book ai didi

php - 未定义索引 php if ($_SERVER ['REQUEST_METHOD' ] == 'POST' ){ 找不到答案?

转载 作者:行者123 更新时间:2023-11-29 16:53:52 30 4
gpt4 key购买 nike

    <form class="login" action="<?php echo $_SERVER['PHP_SELF'] ?>" method="POST">
<h4 class="text-center">Admin Login</h4>
<input class="form-control" type="text" name="user" placeholder="Username" autocomplete="off"/>
<input class="form-control" type="password" name="pass" placeholder="Password" autocomplete="new-password"/>
<input class="btn btn-primary btn-block" type="submit" value="Login">
</form>

我在php上制作了method="POST"表单

if ($_SERVER['REQUEST_METHOD'] == 'POST' ){

$username = $_POST['user'];
$pass = $_POST['pass'];
$hashPass = sha1($pass);

$stmt = $con->prepare("SELECT Username,Password FROM users WHERE Username = ? AND Password = ?");
$stmt->execute(array($username,$hashPass));
$count =$stmt->rowCount();

echo $count;

但结果

Notice: Undefined index: user in C:\xampp\htdocs\eCommerc\admin\index.php on line 7

Notice: Undefined index: pass in C:\xampp\htdocs\eCommerc\admin\index.php on line 8

最佳答案

这个问题是因为Windows操作系统没有启用某些PHP

确保使用 phpinfo() 函数不会找到 REQUEST_METHOD 的方法

所以更换操作系统或者尝试使用其他方法

关于php - 未定义索引 php if ($_SERVER ['REQUEST_METHOD' ] == 'POST' ){ 找不到答案?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52677699/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com