PHP + HTML Form: The email I receive does not show the info that the user types in
Copy link to clipboard
Copied
For some reason when a user submits this form, I'll get in an email back and only see the following:
From:
Email:
Address:
Here is my PHP file (note: I blocked my email address):
<?php
/* Set e-mail recipient */
$myemail = <My email goes here>
$subject = "Registration Form";
/* Check all form inputs using check_input function */
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$address = $_POST['address'];
$city = $_POST['city'];
$state = $_POST['state'];
$zip = $_POST['zip'];
$tel = $_POST['tel'];
$email = $_POST['email'];
$dept = $_POST['dept'];
$course = $_POST['course'];
/* Let's prepare the message for the e-mail */
$message = "Form details below.\n\n";
$message = "From: $first_name\n E-Mail: $email\n Address:\n $address";
$subject ="Registration Form";
/* Send the message using mail() function */
mail($myemail, $subject, $message);
/* Redirect visitor to the thank you page */
header('Location: thanks.html');
exit();
/* Functions we used */
function check_input($data, $problem='')
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
if ($problem && strlen($data) == 0)
{
show_error($problem);
}
return $data;
}
function show_error($myError)
{
?>
<html>
<body>
<b>Please correct the following error:</b><br />
<?php echo $myError; ?>
</body>
</html>
<?php
exit();
}
?>
function clean_string($string) { | $bad = array("content-type","bcc:","to:","cc:","href"); | return str_replace($bad,"",$string); | } |
Copy link to clipboard
Copied
The HTML form must contain the exact same names as your script.

