I have a form which can be seen below:
<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>
It calls this script:
<?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();
?>
I am getting this error:
Notice: Undefined index: email in C:\wamp\www\Holding page\register.php on line 3
What am I doing wrong? I understand that no index called email exists in the POST array but I am unsure why this is the case. Thanks!
print_r($_POST);to check what are the values stored in$_POST.