David Biga
David Biga

Reputation: 2801

issue with form submitting in wordpress

Hey guy so I have this form I created that slides out and you can contact with it, located in the header. For some reason if I submit it, it tells me page cannot be found - I made a page and gave it a template that sends the email. If I just hit the submit button with no values it goes to the page with the thank you message.

Contact 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 -->

TEMPLATE CODE:

<?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(); ?>

Upvotes: 0

Views: 69

Answers (2)

David Biga
David Biga

Reputation: 2801

So I was able to fix my problem with replacing the top form <p><label>Name: </label><input type="text" name="name"/></p>with <p><label>Email: </label><input type="text" name="email"/></p> and just changing values. That's it :) I think it was a spacing issue so that could be why.

Upvotes: 0

kittycat
kittycat

Reputation: 15045

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

You need to make sure the action URL is correctly pointing to your form. The current above one is looking to see if contactformsubmit is one directory above the contact form. It is likely in the same folder, so try:

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

Also in case you meant to have an extension, I don't know your specific SEO setup, but this may also be what you meant:

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

If these don't work please post the filepaths and full names of the contact form and contactformsubmit so we can setup the URL correctly.

Upvotes: 1

Related Questions