https://premium.wpmudev.org/blog/how-to-build-your-own-wordpress-contact-form-

I did as the direction requested and I have text in the fields on the site http://www.coverandcare.com/contact-us. Can someone tell me what I did wrong I don't have a twenty twelve theme I have a twenty fifteen theme. I did all as directions said placed a folder in the wp-content/theme named contact-form then I placed the code below in the style.css
/*
Theme Name: Contact Form Page Template
Theme URI: http://wpmu.org/
Description: A super simple, self-contained contact form you can drop into your existing theme.

Author: Harley
Author URI: https://premium.wpmudev.org/
Template: twentyfifteen
Version: 0.1
*/

I don't know whats wrong can anyone help me please.
@import url("../twentytfifteen/style.css":wink:;

  • Michelle Shull

    Hey there, Vincent!

    I'm not sure what's happening here, I'm not able to reproduce it. I'm going to ask you to try the pre-packaged version of the child theme that was attached to the original blog post, I'll attach it here as well. I think you may have missed one of the steps later on in the original tutorial. I've already made the changes to styles.css to work with twentyfifteen instead of twentytwelve, and it's working on my site.

    1. Download the attached zip file.
    2. Install via Upload New Theme, and activate.
    3. Check your yoursite.com/contact-us/ page and see if you see the correct form.

    Thanks, Vincent!

  • Vincent

    It is still not working I had used the two files you gave me and they are not working.
    Below is whats in my wp-content/themes/contact-form/page-contact-us.php
    and the wp-content/themes/contact-form/style.css
    /*
    Theme Name: Contact Form Page Template
    Theme URI: http://wpmu.org/
    Description: A super simple, self-contained contact form you can drop into your existing theme.
    Author: Harley
    Author URI: https://premium.wpmudev.org/
    Template: twentyfifteen
    Version: 0.1
    */

    @import url("../twentyfifteen/style.css");

    <?php

    //response generation function

    $response = "";

    //function to generate response
    function my_contact_form_generate_response($type, $message){

    global $response;

    if($type == "success") $response = "<div class='success'>{$message}</div>";
    else $response = "<div class='error'>{$message}</div>";

    }

    //response messages
    $not_human = "Human verification incorrect.";
    $missing_content = "Please supply all information.";
    $email_invalid = "Email Address Invalid.";
    $message_unsent = "Message was not sent. Try Again.";
    $message_sent = "Thanks! Your message has been sent.";

    //user posted variables
    $name = $_POST['message_name'];
    $email = $_POST['message_email'];
    $message = $_POST['message_text'];
    $human = $_POST['message_human'];

    //php mailer variables
    $to = get_option('admin_email');
    $subject = "Someone sent a message from ".get_bloginfo('name');
    $headers = 'From: '. $email . "\r\n" .
    'Reply-To: ' . $email . "\r\n";

    if(!$human == 0){
    if($human != 2) my_contact_form_generate_response("error", $not_human); //not human!
    else {

    //validate email
    if(!filter_var($email, FILTER_VALIDATE_EMAIL))
    my_contact_form_generate_response("error", $email_invalid);
    else //email is valid
    {
    //validate presence of name and message
    if(empty($name) || empty($message)){
    my_contact_form_generate_response("error", $missing_content);
    }
    else //ready to go!
    {
    $sent = wp_mail($to, $subject, strip_tags($message), $headers);
    if($sent) my_contact_form_generate_response("success", $message_sent); //message sent!
    else my_contact_form_generate_response("error", $message_unsent); //message wasn't sent
    }
    }
    }
    }
    else if ($_POST['submitted']) my_contact_form_generate_response("error", $missing_content);

    ?>

    <?php get_header(); ?>

    <div id="primary" class="site-content">
    <div id="content" role="main">

    <?php while ( have_posts() ) : the_post(); ?>

    <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

    <header class="entry-header">
    <h1 class="entry-title"><?php the_title(); ?></h1>
    </header>

    <div class="entry-content">
    <?php the_content(); ?>

    <style type="text/css">
    .error{
    padding: 5px 9px;
    border: 1px solid red;
    color: red;
    border-radius: 3px;
    }

    .success{
    padding: 5px 9px;
    border: 1px solid green;
    color: green;
    border-radius: 3px;
    }

    form span{
    color: red;
    }
    </style>

    <div id="respond">
    <?php echo $response; ?>
    <form action="<?php the_permalink(); ?>" method="post">
    <p><label for="name">Name: <span>*</span> <input type="text" name="message_name" value="<?php echo esc_attr($_POST['message_name']); ?>"></label></p>
    <p><label for="message_email">Email: <span>*</span> <input type="text" name="message_email" value="<?php echo esc_attr($_POST['message_email']); ?>"></label></p>
    <p><label for="message_text">Message: <span>*</span> <textarea type="text" name="message_text"><?php echo esc_textarea($_POST['message_text']); ?></textarea></label></p>
    <p><label for="message_human">Human Verification: <span>*</span> <input type="text" style="width: 60px;" name="message_human"> + 3 = 5</label></p>
    <input type="hidden" name="submitted" value="1">
    <p><input type="submit"></p>
    </form>
    </div>

    </div><!-- .entry-content -->

    </article><!-- #post -->

    <?php endwhile; // end of the loop. ?>

    </div><!-- #content -->
    </div><!-- #primary -->

    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    P.S I fallowed the directions whats wrong.
    As you can see the site coverandcare.com/contact-us is not working there is scripts in the fields.

  • Michelle Shull

    Hey there, Vincent!

    Two possible things to try:
    1. What version of PHP is running on your server?
    2. Are you using any other plugins on the site you're trying to add the contact form to? If so, can you try disabling them and see if you get blank fields without the PHP code in them?

    The code you have here is fine, it matches what I have exactly. There must be something else going on here.

    Ultimately, this method of importing the settings into a child theme is outdated, but I'm not sure what the workaround would be to create a child theme for this while following the proper procedure. Don't worry about that now, let's just see if we can make it work. :slight_smile:

  • Vincent

    Tell me how to start over I have your files and I have created two files style.css and page-contact-us.php

    What do I do with the script in your files your first step is confusing in your directions to pad it out what dose this mean.
    You make this so confusing if I left my page-contact-us.php blank That’s alright though! Quickly pad it out with the following, and it will look just like a normal page again.

    This is confusing I must say.

    Why don't you tell me what to do with the two files you sent me or should I leave them empty and then place what code in them. Your script was fallowed directly.
    I created two files a style.css and a page-contact-us.php in the wp-content/themes
    Then I placed your css that was in your files style.css into my file style.css
    Then I placed the scripts in the file page-contact-us.php then I placed the other script after that were it says the Replace the FORM CODE GOES HERE paragraph with the following:
    I use the script below and took out form goes here and placed the script below that you have there in between the two <P>script</p>
    What else is ther to do

  • Michelle Shull

    Hi there, Vincent.

    I see the problem.

    The two files I gave you should go into a folder called contact-form in your themes folder. Do not copy the CSS to your style.css folder, leave it in the contact-form folder, next to page-contact-us.php.

    OR, delete both of those files and do the following.

    1. Go to Themes > Add New > Upload Theme

    2. Select the zip file I gave you from your local computer from the upload screen. DO NOT UNZIP FIRST.

    3. Activate the child theme from Appearances > Themes.

    That will make it work. :slight_smile:

  • Vincent

    I don't know what you mean child theme I have three themes in there called twenty fifteen twenty fourteen twenty thirteen. The active theme right now is twenty fifteen.
    I am lost ok lets start this over I have deleted the files in the themes section.
    Now what am I suppose to do with this twenty fifteen theme. Upload what theme the theme already in there. Do you want me to deactivate it and activate it again you are confusing me.

    Regards Vinny

    Regards Vinny

  • Jude

    Sorry the response took a while longer than expected. Appreciate your patience. Looks like Michelle is really busy and this one slipped through the gaps, I'm gonna take the liberty of chipping in here.

    You can read more about child themes here
    https://codex.wordpress.org/Child_Themes
    premium.wpmudev.org/blog/how-to-create-wordpress-child-theme/

    At this point I'd really recommend you just get a simple plugin to help with this you can try
    https://wordpress.org/plugins/simple-contact-form/
    https://wordpress.org/plugins/very-simple-contact-form/
    https://wordpress.org/plugins/simple-basic-contact-form/

    OR use Jetpack
    https://wordpress.org/plugins/jetpack/

    I say this because you'd save a lot of time you can use elsewhere as opposed to coding one from scratch

    Cheers
    Jude

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.