我有一个联系方式,我以前在其他非WP网站上使用过很多次,但在我的current WP site, 它只是将您重定向到找不到的页面。
我不想使用任何插件来创建它。
代码如下:
<form class="form" method="POST" action="<?php the_permalink(); ?>">
<table border="0" style="float:left;">
<tbody>
<tr>
<td>
<p>Company Name:</p>
</td>
<td> </td>
<td><input type="text" name="companyname" id="companyname" /></td>
</tr>
<tr>
<td>
<p>Your Name:</p>
</td>
<td> </td>
<td><input type="text" name="name" id="name" /></td>
</tr>
<tr>
<td>
<p>E-mail:</p>
</td>
<td> </td>
<td><input type="text" name="email" id="email" /></td>
<td colspan="2"> </td>
</tr>
<tr>
<td>
<p>Telephone:</p>
</td>
<td> </td>
<td><input type="text" name="tel" id="tel" /></td>
<td colspan="2"> </td>
</tr>
</tbody>
</table>
<table border="0" style="float:left;" width="450">
<tbody>
<tr>
<td valign="top"><p style="margin-left:42px;margin-right:10px;margin-top:7px;">Enquiry:</p></td>
<td><textarea name="enquiry"></textarea></td>
</tr>
<tr>
<td colspan="2"><button class="blue medium awesome awesomeforward" type="submit" name="submit">Send message</button></td>
</tr>
</tbody>
</table>
<? if(isset($_POST[\'submit\'])) {
$to = "[email protected]";
$subject = "Teamworks contact enquiry";
$companyname_field = $_POST[\'companyname\'];
$name_field = $_POST[\'name\'];
$email_field = $_POST[\'email\'];
$tel_field = $_POST[\'tel\'];
$enquiry_field = $_POST[\'enquiry\'];
$body = "Hello Teamworks,\\n\\n You have an enquiry from the website, please see the details below:\\n\\n Name: $name_field\\n Company Name: $companyname_field\\n E-Mail: $email_field\\n Tel: $tel_field\\n Message:\\n $enquiry_field\\n\\n Please reply to the enquiry asap.\\n\\n Kind Regards \\n The Teamworks Website";
mail($to, $subject, $body);
echo "</br>Thank you for getting in touch, we will contact you shortly.";
} ?>
</form>
最合适的回答,由SO网友:Bainternet 整理而成
在处理表单时,您需要确保您的表单没有几个特定的字段名称,如:name、day、month、year,我确信还有一些,因此请确保您的表单字段名称更具体,如:contact\\u name、contact\\u day、contact\\u month、contact\\u year。
在你的情况下,改变name="name"
其他任何事情。