我有一个表格,如下所示:
<form id="myForm" action="register.php" method="POST">
<input type="text" name="email" id="email" onfocus="fieldSwap('inputhover.png')"
onblur="fieldSwap('inputnorm.png')"><br/>
<input type="image" src="submitnorm.png" name="submit" id="submit"
alt="submit button" onMouseOver="buttonSwap('submithover.png')"
onMouseOut="buttonSwap('submitnorm.png')"
onMouseDown="buttonSwap('submitclick.png')"
onMouseUp="buttonSwap('submitnorm.png')"/>
</form>
它调用这个脚本:
<?php
require_once 'db.php';
$email = $_POST['email'];
echo $email;
echo "Register form";
$sql->$db->prepare("INSERT INTO emails SET email = :email");
$sql -> bindValue(':email', $email, PDO::PARAM_STR);
$sql -> execute();
// Redirect back to homepage
header('Location: index.php');
exit();
?>
我收到此错误:
注意:未定义索引:第 3 行 C:\wamp\www\Holding page\register.php 中的电子邮件
我究竟做错了什么?我知道 POST 数组中不存在名为 email 的索引,但我不确定为什么会这样。谢谢!