Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7915299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T14:24:42+00:00 2026-06-03T14:24:42+00:00

I would like to point out that I’m not really a developer, but rather

  • 0

I would like to point out that I’m not really a developer, but rather a designer. I’m trying to fit a custom contact form on a WordPress Template file. It works on principle based on a tutorial that’s at Cats Who Code: How to create a built-in contact form for your WordPress theme.

I have modified the contact form to have the following:

  • Name (Text Field)
  • Company (Text Field)
  • Address (Text Area)
  • Email Address (Text Field)
  • Telephone (Text Field)
  • Mobile (Text Field)
  • Enquiry (Text Area)

However, when I integrate it into a custom template, and put it on the WordPress install, it just gives me a blank page, with blank code. I am wondering why this is happening, and when I remove the contact form from the template, it’s all good without the contact form. Here is the entire template code below.

<?php
if(isset($_POST['submitted'])) {
if(trim($_POST['name']) === '') {
    $nameError = 'Please enter your name.';
    $hasError = true;
} else {
    $name = trim($_POST['name']);
}
if(trim($_POST['company']) === '') {
    $companyError = 'Please enter your company name.';
    $hasError = true;
} else {
    $company = trim($_POST['company']);
}
if(trim($_POST['address']) === '') {
    $addressError = 'Please enter your address.';
    $hasError = true;
} else {
    if(function_exists('stripslashes')) {
        $address = stripslashes(trim($_POST['address']));
    } else {
        $address = trim($_POST['address']);
    }
}
    if(trim($_POST['email']) === '')  {
    $emailError = 'Please enter your email address.';
    $hasError = true;
} else if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$", trim($_POST['email']))) {
    $emailError = 'You entered an invalid email address.';
    $hasError = true;
} else {
    $email = trim($_POST['email']);
}
if(trim($_POST['telephone']) === '') {
    $telephoneError = 'Please enter your telephone number.';
    $hasError = true;
} else {
    $telephone = trim($_POST['telephone']);
}
if(trim($_POST['mobile']) === '') {
    $mobileError = 'Please enter your mobile phone number.';
    $hasError = true;
} else {
    $mobile = trim($_POST['mobile']);
}
if(trim($_POST['enquiry']) === '') {
    $enquiryError = 'Please enter a message.';
    $hasError = true;
} else {
    if(function_exists('stripslashes')) {
        $enquiry = stripslashes(trim($_POST['enquiry']));
    } else {
        $enquiry = trim($_POST['enquiry']);
    }
}

if(!isset($hasError)) {
    $emailTo = get_option('tz_email');
    if (!isset($emailTo) || ($emailTo == '') ){
        $emailTo = get_option('admin_email');
    }
    $subject = '[Blue Doors] From '.$name;
    $body = "Name: $name \n\nCompany: $company \n\nAddress: $address \n\nEmail: $email \n\nTel: $telephone \n\nMobile: $mobile \n\nDetails of Enquiry: $enquiry";
    $headers = 'From: '.$name.' <'.$emailTo.'>' . "\r\n" . 'Reply-To: ' . $email;

    mail($emailTo, $subject, $body, $headers);
    $emailSent = true;
}
} ?>

<?php get_header(); ?>

<section class="content">
    <?php if(have_posts()) : ?><?php while(have_posts()) : the_post(); ?>

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

        <article class="content-body">  
            <?php the_post_thumbnail(); ?>
            <?php the_content(); ?>
        </article>

        <article class="content-body">

        <?php if(isset($emailSent) && $emailSent == true) { ?>
                        <div class="thanks">
                            <p>Thanks, your email was sent successfully.</p>
                        </div>
                        <?php } else { ?>
                        <?php the_content(); ?>
                        <?php if(isset($hasError) || isset($captchaError)) { ?>
                            <p>Sorry, an error occured.<p>
                        <?php } ?>

            <form action="<?php the_permalink(); ?>" id="contactform" method="post">
                <ul>
                    <li>
                        <label>What is your name?</label>
                        <input type="text" name="name" id="name" value="<?php if(isset($_POST['name'])) echo $_POST['name'];?>" class="required"/>
                        <?php if($nameError != '') { ?>
                                <span class="error"><?=$nameError;?></span>
                            <?php } ?>
                    </li>
                    <li>
                        <label>What is your company's name?</label>
                        <input type="text" name="company" id="company" value="<?php if(isset($_POST['company'])) echo $_POST['company'];?>" class="required"/>
                    </li>
                    <li>
                        <label class="address">What is your address?</label>
                        <textarea name="address" id="address" rows="5" cols="30" class="required"><?php if(isset($_POST['address'])) { if(function_exists('stripslashes')) { echo stripslashes($_POST['address']); } else { echo $_POST['address']; } } ?></textarea>
                            <?php if($addressError != '') { ?>
                                <span class="error"><?=$addressError;?></span>
                            <?php } ?>
                    </li>
                    <li>
                        <label>What is your email address?</label>
                        <input type="text" name="email" id="email" value="<?php if(isset($_POST['email'])) echo $_POST['email'];?>" class="required" />
                            <?php if($emailError != '') { ?>
                                <span class="error"><?=$emailError;?></span>
                            <?php } ?>
                    </li>
                    <li>
                        <label>What is your telephone no?</label>
                        <input type="text" name="telephone" id="telephone" value="<?php if(isset($_POST['telephone'])) echo $_POST['telephone'];?>" class="required" />
                            <?php if($nameError != '') { ?>
                                <span class="error"><?=$telephoneError;?></span>
                            <?php } ?>
                    </li>
                    <li>
                        <label>What is your mobile no?</label>
                        <input type="text" name="mobile" id="mobile" value="<?php if(isset($_POST['mobile'])) echo $_POST['mobile'];?>" class="required" />
                            <?php if($mobileError != '') { ?>
                                <span class="error"><?=$mobileError;?></span>
                            <?php } ?>
                    </li>
                    <li>
                        <label>What would you like to discuss about with Blue Doors?</label>
                        <textarea name="enquiry" id="enquiry" rows="8" cols="30" class="required"><?php if(isset($_POST['enquiry'])) { if(function_exists('stripslashes')) { echo stripslashes($_POST['enquiry']); } else { echo $_POST['enquiry']; } } ?></textarea>
                            <?php if($enquiryError != '') { ?>
                                <span class="error"><?=$enquiryError;?></span>
                            <?php } ?>
                    </li>
                    <li>
                        <button type="submit" class="submitbutton">Submit your enquiry</button>
                    </li>
                </ul>
                <input type="hidden" name="submitted" id="submitted" value="true" />
            </form>
        </article>

    <?php endwhile; endif; ?>

</section>

<?php get_sidebar(); ?>

<?php get_footer(); ?>

I’m trying to figure out where it’s breaking but I’m not really any good with PHP nor can understand it. Could anyone point out where I’m going wrong, it would be much appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T14:24:42+00:00Added an answer on June 3, 2026 at 2:24 pm

    You had put your contact form code inside the loop <?php if(have_posts()) : ?><?php while(have_posts()) : the_post(); ?>

    Try put the whole contact form code starting from <?php if(isset($emailSent) && $emailSent == true) { ?> to </form> outside the loop. ie put that code part after this line <?php endwhile; endif; ?>

    Hope this will help.

    EDIT:

    You are missing one curly braces on the code. Update the below part of code. I had only added one more braces at the last line.

    <?php if(isset($emailSent) && $emailSent == true) { ?>
                            <div class="thanks">
                                <p>Thanks, your email was sent successfully.</p>
                            </div>
                            <?php } else { ?>
                            <?php the_content(); ?>
                            <?php if(isset($hasError) || isset($captchaError)) { ?>
                                <p>Sorry, an error occured.<p>
                            <?php } } ?>
    

    And it is perfectly working for me.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

At first I would like to point out, that I am not a JQuery
First off, before I ask, i would like to point out that this question
Before I begin, I would like to point out that I have honestly and
I would like to point out before I get into this that I am
We're approaching a point of replacing several of our developer PCs and would like
I would like to point out a 'risky' part in F#. Consider the following
First, I'd like to point out that this question is probably already asked, I
Hi I am sending email attachments (using php) and would like to point out
first i'd like to point out that im fairly new to netbeans and java,
I would like to test if a point is within a particular distance of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.