里面每个人+ PHP我有我的联系方式在HTML和PHP(2个不同的文件,一个HTML和一个PHP文件)准备好,我想在一个页面worpress使用它。 用户填写表格,选择支持部门应答验证码并按提交按钮。表单通过电子邮件将所有表单数据发送给管理员,感谢您通过电子邮件发送给用户并重定向至感谢页面。 HTML表单是WordPress的自定义联系人窗体的html页面
<html>
<body>
<head>
<script src="http://www.google.com/recaptcha/api.js" async defer> </script>
<script type="text/javascript" src="http://www.google.com/recaptcha/api/js/recaptcha_ajax.js"></script>
</head>
<i>Use the form to get in touch with us.</i>
<form action="form.php" method="POST">
<strong>Name:*</strong>
<input style="width:300px;" name="username" type="text" required />
<strong>E-mail Adress:*</strong>
<input style="width:300px;" name="useremail" type="text" required />
<strong>Subject:*</strong>
<input style="width:300px;" name="usersubject" type="text" required />
<strong>Message:*</strong>
<textarea style="width:300px;" cols="40" name="usermessage" rows="5" required></textarea>
<strong>Select Support Department </strong>
<select name="support">
<option style="width:200px;" value="" >Choose Service</option>
<option style="width:200px;" value="[email protected]" required>Technical support</option>
<option style="width:200px;" value="[email protected]" required>Sales</option>
<option style="width:200px;" value="[email protected]" required>Press</option>
<option style="width:200px;" value="[email protected]" required>Other</option>
</select>
//recaptcha
<div class="g-recaptcha" data- sitekey="------my site key---------"></div>
<input type="submit" value="send" name="submit"/>
//it redirects when you hit submit
<?php
if (isset($_POST['submit'])){
header("Location:http://xxxxxxxxx.com/thank-you-messasge/");
}
?>
</form>
</html>
</body>
我form.php的是
<?
//set up the message for administrator
$msg="Name:".$_POST["username"]."\n";
$msg .="E-mail:".$_POST["useremail"]."\n";
$msg .="Subject:".$_POST["usersubject"]."\n";
$msg .="Usermessage:".$_POST["usermessage"]."\n";
//set up message for customer
$msg_customer="We received your request and we will answer you within 24 hours.";
$msg_customer.="\n"."xxxxxxxxxxxxxx";
//set up the email for the administrator
$recipient=$_POST["support"];
$subject= "Support Contact Form ";
$mailheaders="From: xxxxxxxx [email protected] \n";
//set up the email for the customer
$recipient_customer=$_POST["useremail"];
$subject_customer= "Support Contact Form ";
$mailheaders_customer="From: xxxxxxxxxx [email protected] \n";
//send the emails
mail($recipient,$subject,$msg, $mailheaders);
mail($recipient_customer,$subject_customer,$msg_customer, $mailheaders_customer);
?>
我想这种形式出现在一个页面上,并能够在按下提交按钮时运行的PHP代码。 我不能运行form.php的文件,即使我将它保存在根目录下。 看来我失去的东西 非常感谢你
喜。也许我没有让我自己清楚。这是一个工作的HTML格式,有一个工作的PHP文件,当我测试它在本地工作正常。问题是我如何设法在wordpress页面中使用它?我希望这不会超出stackoverflow的范围,因为它是我的第一篇文章。我发现很多关于wordpress的帖子,尽管没有一个是有用的。 – xbass540 2015-02-09 23:06:30
你可以只复制和形式HTML粘贴到网页的'code'观点,但TinyMCE有搞乱复杂的HTML的方式。一个更好的卧牛是创建表单代码[页面模板](http://codex.wordpress.org/Page_Templates)(复制从你的主题现有模板)。你也可以[做一个简码](http://codex.wordpress.org/Shortcode)插入你的代码。 – cpilko 2015-02-09 23:12:31
好的。我正在使用编辑器的文本模式,所以这种方式我没有得到我的代码剥离。但关于:
我应该在哪里放置form.php文件? – xbass540 2015-02-09 23:36:13