在wordpress中提交表单的问题

时间:2012-12-15 23:44:50

标签: php 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(); ?>

2 个答案:

答案 0 :(得分:1)

<form method="post" action="../contactformsubmit">

您需要确保操作网址正确指向您的表单。上面的当前版本正在查看contactformsubmit是否是联系表单上方的一个目录。它可能在同一个文件夹中,所以请尝试:

<form method="post" action="contactformsubmit">

如果您打算使用扩展程序,我不知道您的具体SEO设置,但这也可能是您的意思:

<form method="post" action="contactformsubmit.php">

如果这些不起作用,请发布联系表单和contactformsubmit的文件路径和全名,以便我们正确设置URL。

答案 1 :(得分:0)

因此,我可以使用<p><label>Name: </label><input type="text" name="name"/></p>替换顶部表单<p><label>Email: </label><input type="text" name="email"/></p>并仅更改值来解决我的问题。就是这样:)我认为这是一个间距问题,所以这可能是原因。