我以前在其他非WP网站上使用过很多次联系表格,但在我当前的WP网站上似乎不起作用,它只是将您重定向到未找到的页面。
我不想使用任何插件来创建它。
这是代码:
<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 = "rob@teamworksdesign.com";
$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>
太好了,谢谢。简单到令人沮丧的时候!!ps我无法将您标记为已回答。
—
罗布
将其添加为答案,以便您可以将此问题标记为已回答。
—
Bainternet 2011年
name="name"
其他名称。