Hi There,
I am experimenting with an email form but the $_POST values are not set. The mail.php script is called correctly but the variables I try to use within the email body are empty.
var_dump($_POST); returns me an empty array - (0) { } - so I am clearly doing something wrong.
Here's the code for the form:
<FORM action="mail.php" method="post" enctype="text/plain">
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="4" WIDTH="90%">
<TR>
<TD width="30%"><DIV align="right"><B>Name:</B></DIV>
<TD width="70%">
<INPUT type="text" name="name" id="name" size="40">
</TD>
</TR>
<TR>
<TD width="30%"><DIV align="right"><B>Email:</B></DIV>
</TD>
<TD width="70%">
<INPUT type="text" name="email" id="email" size="40">
</TD>
</TR>
<TR>
<TD width="30%"><DIV align="right"><B>Can you make it?:</B></DIV>
<TD><select name="attendance" id="attendance" accesskey="1" tabindex="1">
<option>Sorry can't make</option>
<option>Yes can't wait</option>
</select></TD>
</TR>
<TR>
<TD><DIV align="right">
<p><B>Names if attending</B><B>:</B></p>
</DIV>
</TD>
<TD><TEXTAREA name="names" id="names" cols="30" wrap="virtual" rows="4">
</TEXTAREA>
</TD></TR>
<TR>
<TD width="30%"><DIV align="right"><B>Any dietry requirements?</B></DIV>
<TD><TEXTAREA name="dietry" id="dietry" cols="30" wrap="virtual" rows="4">
</TEXTAREA>
</TD>
</TR>
<TR>
<TD> </TD>
<TD>
<INPUT type="submit" name="submit" value="Submit">
<INPUT type="reset" name="reset" value="Reset">
</TD></TR>
</TABLE>
</FORM>
And here's the php script:
<?php
$name= $_POST['name'];
$email=$_POST['email'];
$attendance=$_POST['attendance'];
$names=$_POST['names'];
$diet=$_POST['dietry'];
$to = "somone@somewhere.com";
$subject = "RSVP";
$body = "Name:'$name'
\n\n Email='$email'
\n\n Attendance='$attendance'
\n\n Names='$names'
\n\n Dietry='$diet';";
var_dump($_POST);
if (mail($to, $subject, $body)) {
echo("<p>Message successfully sent!</p>");
} else {
echo("<p>Message delivery failed...</p>");
}
?>
All help appreciated.
Tim.