所以我正在使用 php 制作一个登录表单,每次提交时我都会收到未定义的索引错误。这是我的表格:
<form action="website.net/validation.php" method="post" enctype="multipart/form-data">
<div class="form-group">
<label>Username</label>
<input type="text" maxlength="255" placeholder="Username" name="user" class="form-control" required />
</div>
<div class="form-group">
<label>Password</label>
<input type="password" maxlength="255" placeholder="Password" name="password" class="form-control" required />
</div>
<hr class="my-4">
<div class="form-group">
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="customCheck1" name="remember" value="yes">
<label class="custom-control-label" for="customCheck1">Remember Me</label>
</div>
</div>
<br>
<p class="lead">
<button type="submit" class="btn btn-primary btn-lg">Login</button>
</p>
</form>
继承人的PHP:
$name = stripslashes($_POST["user"]);
$pass = stripslashes($_POST["password"]);
这显然只是意味着我拼错了某些东西或者没有设置值,对吧?错误的。我检查了我在 html 和 php 中的所有拼写,我也已经完成var_dump($_POST["user"]);并打印出用户名。表单元素是必需的,因此不能不设置它们。我试过用 htmlentities() 包围变量。我试过将它们包围在 if then 块中以测试 ifset。没有什么能解决这个问题。我不知道为什么这不起作用。有人可以帮忙吗?谢谢
整个 php 错误:
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
session_start();
var_dump($_POST);
$name = stripslashes($_POST["user"]);
$pass = stripslashes($_POST["password"]);
互换的青春