表格:
<form action="/HW2/controllers/login.php" id = "login-box" method = "post">
Username: <input type="text" name='user'><br>
Password: <input type="text" name='pwd'><br>
<input type="submit">
</form>
那个行动:
<?php
require("../config/config.php");
if(isset($_POST['user']) && isset($_POST['pwd'])){
if(strcmp($_POST['user'], USERNAME) == 0 && strcmp($_POST['pwd'],
PASSWORD) == 0){
session_start();
$_SESSION['logon'] = true;
echo "success";
//header("location: /HW2/index.php?view=loggedin");
}else{
print_r("Sorry, your username and/or password are invalid. Try Again?");
//header("location: /HW2/index.php?view=loginPage");
}
}else{
print_r("Post data not sent.");
}
?>
我尝试了许多不同的方法,所有结果都导致“未发送发布数据。”(如果我尝试访问 $_POST 值,又名“未定义索引:”)一直试图找到我搞砸了好几个小时的东西,任何帮助表示赞赏,我是 php 的彻底磨砂,这可能是非常简单和愚蠢的事情。
提前致谢!