嘿傢伙,所以我有這種形式我創造了幻燈片出來,你可以與它聯繫,位於標題。由於某種原因,如果我提交它,它告訴我無法找到頁面 - 我製作了一個頁面,並給它一個發送電子郵件的模板。如果我只是按下沒有任何值的提交按鈕,就會通過謝謝信息進入頁面。問題與表格提交在wordpress
聯繫CODE:
<div id="feedback"><!-- Sliding contact form ---->
<form method="post" action="../contactformsubmit">
<h2>Phone: 847-782-9816</h2>
<p><label>Name: </label><input type="text" name="name"/></p>
<p><label>Email: </label><input type="text" name="email"/></p>
<p><label>Subject: </label><input type="text" name="subject"/></p>
<p><label>Message: </label><textarea name="message"></textarea></p>
<p><input type="submit" value="Send" class="btn"/></p>
</form>
<a href="#" class="pull_feedback" title="Click to leave feedback" ><img src=""/>Feedback</a>
</div>
<!-- end contact form -->
模板代碼:
<?php
/*
Template Name: formsubmit
*/
session_start();
get_header(); ?>
<style>
.item-post{
margin: 0 0 1.625em;
padding: 0 0 1.625em;
position: relative;
float: left;
height: 365px;
width: 100%;
margin-left: 2%;
}
.singular .item-post{
text-align:center;
}
.singular.page .hentry {
padding:0 0 0 0;
width: 17%;
margin-top:1em;
//height: 405px;
}
.singular.page .hentry:hover{
background: #C9191B;
}
.singular .entry-title {
font-size: 15px;
width: 100%;
text-align: center;
}
.singular .entry-content {
width:100%;
}
.singular .entry-header {
width:100%;
text-align:center;
}
.singular .discription {
width: 80%;
text-align: left;
font-size: 12px;
padding-left: 15%;
height: 12%;
}
.singular .prodslideshow {
display:none;
}
.singular .pricing {
padding-left: 15%;
}
</style>
<div id="primary">
<div id="content" role="main">
<div class="thankyou" style="text-align:center; padding-top:1em; padding-bottom:1em;">
<h2>Thank you for contacting us! We are here to make sure your time with us is a good one! We will contact you as soon as we can.</h2>
</div>
<?php
$message = $_POST['message'];
$name = $_POST['name'];
$email = $_POST['email'];
$subject = $_POST['subject'];
/*******SEND EMAIL**********/
require_once "Mail.php";
$body = "
Message from contact form!
$name
$email
$message
";
// Send
$from = "Contact Form ";
//$to = "";
$to = "";
$host = "";
$username = "";
$password = "";
$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject);
$smtp = Mail::factory('smtp',
array ('host' => $host,
'auth' => true,
'username' => $username,
'password' => $password));
$mail = $smtp->send($to, $headers, $body);
?>
</div><!-- #content -->
</div><!-- #primary -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
我用../contactformsforms,因爲在wordpress中,如果你在不同的頁面上,它會堆疊它......我不需要.php,因爲wordpress如何格式化它的頁面。該頁面是contactsformsubmit和模板是它連線到發送電子郵件,這是一個.php文件,但你忽略,因爲如何wordpress的作品。 –
頁面的網址是'sitedir/contactformsubmit' –
如果sitedir是根文件夾,那麼請執行action =「/ sitedir/contactformsubmit」 –