我无法让我的 PHP 联系表正常工作。我正在尝试在一页中完成它,并希望得到任何帮助。我想将其保留为表格格式。我已经搜索过,但找不到正确的 POST/if isset 格式。任何帮助将不胜感激。
PHP:
<html>
<body>
<?php
$action=$_REQUEST['action'];
if ($action=="")
{
echo "<table width=\"360\" cellpadding=\"2\" cellspacing=\"0\">";
echo " <tr>";
echo " <td width=\"20%\"><span id=\"rfvname\">* Name:</span></td>";
echo " <td><input type=\"text\" name=\"name\" value=\"\" /></td>";
echo " </tr>";
echo " <tr>";
echo " <td><span id=\"rfvemail\">* Email:</span></td>";
echo " <td><input type=\"text\" name=\"email\" value=\"\" /></td>";
echo " </tr>";
echo " <tr>";
echo " <td>Comments:</td>";
echo " <td><textarea name=\"comments\" rows=\"5\" cols=\"15\"></textarea></td>";
echo " </tr>";
echo " <tr>";
echo " <td> </td>";
echo " <td><input type=\"submit\" value=\"Submit\" class=\"btnSubmit\" id=\"btnSubmit\" name=\"submit\" /></td>";
echo " </tr>";
echo "</table> ";
}
else
{
$name=$_REQUEST['name'];
$email=$_REQUEST['email'];
$comments=$_REQUEST['comments'];
if (($name=="")||($email=="")||($comments==""))
{
echo "All fields are required, please fill <a href=\"\">the form</a> again.";
}
else{
$to = 'email@email.com';
$from="From: $name<$email>\r\nReturn-path: $email";
$subject="Message sent using your contact form";
mail($to, $subject, $comments, $from);
echo "Email sent!";
}
}
?>
</body>
</html>