I have made a form that I would like to be sent through email when the user submits the form. I have gotten the form to send the email as an html email, but I am not able to get the information that the user inputs into the form.
This is the code that I am using for the form....
<html>
<head>
<title>Feedback</title>
</head>
<body>
<form method="POST" action="confirm.php">
Your Name: <input type="text" name="Name" size="20"><br>
Your Age: <input type="text" name="Age" size="20"><br>
Your feedback: <textarea rows="2" name="Reason" cols="20"></textarea><br>
<input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2">
</form>
</body>
</html>
.....and this is the code on the confirm.php page.....
<html>
<head>
<title>Thank you for sending this information</title>
</head>
<body>
<?
if ($Name)
{
print ("$Name<br>");
}
else
{
print ("You appear to not have a name!<br>");
}
if ($Age)
{
print ("$Age<br>");
}
else
{
print ("Do you even know how old you are?<br>");
}
if ($Reason)
{
print ("$Reason<br>");
}
else
{
print ("You did not enter any feedback!<br>");
}
?>
<?
/ recipients /
$to = "Roadrunner <email@domain.net>";
/ subject /
$subject = "Feedback from website";
/ message /
$message = '
<html>
<head>
<title>Feedback</title>
</head>
<body>
<p><font color="ff0000"><b>Feedback Form:</b></font></p>
<table>
<tr>
<td>
<?
if ($Name)
{
print ("$Name");
}
if ($Age)
{
print ("$Age");
}
if ($Reason)
{
print ("$Reason");
}
?>
</td>
</tr>
</table>
</body>
</html>
';
/ To send HTML mail, you can set the Content-type header. /
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
/ additional headers /
$headers .= "From: Feedback Form <email@domain.net>\r\n";
$headers .= "Cc: email@domain.net\r\n";
$headers .= "Bcc: email@domain.net\r\n";
/ and now mail it /
mail($to, $subject, $message, $headers);
?>
</body>
</html>
Can someone please point me in the right direction to get the email to display the fields that are entered on the form?