I have very limited knowledge of PHP so I used a contact form generator, but it does not function properly. The email does send successfully, but only the "email" and the "option" popups gets detected. Anything else returns empty.
Here is the code.
form.php
<?=$message?>
<form id="FormName" action="send.php" method="post" name="FormName">
<table width="448" border="0" cellspacing="2" cellpadding="0">
<tr><td width = "150" align="right"><label for="EmailFrom">Your E-mail</label></td>
<td><input id="EmailFrom" type="text" name="EmailFrom" size="25"></td></tr>
<tr><td width = "150" align="right" valign="top"><label for="text_field">text field</label></td>
<td valign="top"><input id="text_field" name="text_field" type="text" size="25" value="<?=$text_field?>" maxlength="255"></td></tr><tr><td width = "150" align="right" valign="top"><label for="hello_world_1">Hello world 1</label></td>
<td valign="top"><input id="hello_world_1" name="hello_world_1" type="checkbox" value="Y"></td></tr><tr><td width = "150" align="right" valign="top"><label for="hello_world_2">Hello world 2</label></td>
<td valign="top"><input id="hello_world_2" name="hello_world_2" type="checkbox" value="Y"></td></tr><tr><td width = "150" align="right" valign="top"><label for="hello_world_3">Hello World 3</label></td>
<td valign="top"><input id="hello_world_3" name="hello_world_3" type="checkbox" value="Y"></td></tr><tr><td width = "150" align="right" valign="top"><label for="text_area">text area</label></td>
<td valign="top"><textarea id="text_area" name="text_area" rows="4" cols="40"><?=$text_area?></textarea></td></tr><tr><td width = "150" align="right" valign="top"><label for="popup">popup</label></td>
<td valign="top"><select id="popup" name="popup" size="1">
<option value="Option 1"<?php if($popup == "Option 1"){echo " selected";}?>>Option 1</option>
<option value="Option 2"<?php if($popup == "Option 2"){echo " selected";}?>>Option 2</option>
<option value="Option 3"<?php if($popup == "Option 3"){echo " selected";}?>>Option 3</option>
</select></td></tr><tr><td width = "150" align="right" valign="top"><label for="date">date</label></td>
<td valign="top"><input id="date" name="<?=$date?>" type="text" size="25" value="<?=$date?>" maxlength="255"></td></tr><tr><td width = "150" align="right" valign="top"><label for="hidden">hidden</label></td>
<td valign="top"><input type="hidden" name="hidden" value="<?=$hidden?>"></td></tr><tr><td width = "150" align="right" valign="top"><label for="image">image</label></td>
<td valign="top"><input type="hidden" name="hidden" value="<?=$hidden?>"></td></tr><tr>
<td width="150"></td>
<td>
<input type="submit" name="submitButtonName" value="Send E-mail"></td>
</tr>
</table>
</form>
send.php
<?php
$EmailFrom = $_POST['EmailFrom'];
$text_field = trim($_POST['text_field']);
$hello_world_1 = trim($_POST['hello_world_1']);
$hello_world_2 = trim($_POST['hello_world_2']);
$hello_world_3 = trim($_POST['hello_world_3']);
$text_area = trim($_POST['text_area']);
$popup = trim($_POST['popup']);
$date = trim($_POST['date']);
$hidden = trim($_POST['hidden']);
$image = trim($_POST['image']);
$EmailTo = "[email protected]";
$Subject = ""; /// Add a subject
$validationOK=true;
if (trim($EmailFrom)=="") $validationOK=false;
if (!$validationOK) {
echo "Error! E-mail was not sent. Please check you code.";
exit;
}
$Body = "";
$Body .= "text field:\n$textfield\n\n";
$Body .= "Hello world 1:\n$helloworld1\n\n";
$Body .= "Hello world 2:\n$helloworld2\n\n";
$Body .= "Hello World 3:\n$helloworld3\n\n";
$Body .= "text area:\n$textarea\n\n";
$Body .= "popup:\n$popup\n\n";
$Body .= "date:\n$date\n\n";
$Body .= "hidden:\n$hidden\n\n";
$Body .= "image:\n$image\n\n";
if($Subject == NULL) {$Subject = "From $EmailFrom";}
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
if ($success){ echo "Success! Your e-mail was sent!";}
else{ echo "Error! Your e-mail was not sent!";}
?>
Why does it not function? Also, if you could recommend a working php form generator, that would be very helpful. I require both checkbox and popup/radiobutton.
Your variables are named like "$text_field" (with underscore) but when appending to $Body you do not use the underscores, e.g. "$textfield". Thus the variable "$textfield" is not even set, meaning empty.