注意:未定义的索引:在第98行的C:\xampp\htdocs\assurance\confirmation.php中确认
$confirm = $_POST['confirm'];
<label> Retype Password </label>
<input type="password" name="confirm" />
您可能无条件地运行表单处理代码,无论表单提交是否实际发生。
你需要这样的东西:
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if (isset($_POST['confirm'])) {
... a post occured, and the confirm field was submitted
}
}
... show the form.
你提交了表格吗?
顺便说一下,通知使用
if(isset($_POST["confirm"])
您正在尝试将变量$confirm尚未设置的值 $_POST['confirm']。向代码添加检查以避免错误。
改变:
$confirm = $_POST['confirm'];
自:
$confirm = ( isset($_POST['confirm'] ) ) ? $_POST['confirm'] : '';
请先检查:
-
您在
<input>
之前有<form>
标签吗?
<form method="POST" action="path/to/file.php"><input name="confirm" type="password"> </form>
-
你有按钮吗?如果您有类似登录表单的内容,则需要一个按钮来"提交"
<input type="submit">
然后在您的文件中写入:
if($_SERVER['REQUEST_METHOD'] == 'POST'){ if(isset($_POST['confirm']){
/* 随心所欲 */
} }