PHP Mail Form, Blank Page on Submit? (2 posts)

  1. chrisando
    Posted 4 years ago #


    Im having some issues with a PHP Mail form i have setup on a wordpress site of mine.

    Once a user fills in the form located at:
    They click submit.
    The page reloads, but without any page content, i would like the contact form to reload.
    Try it, too see the result.

    Here is my code for the contact page (using a custom page template)

    <?php /* Template Name: LOTR_Meet */ ?>
    <?php get_header(); ?>
    <div id="left">
        <div class="post">
        	<div class="post_title"><h1 class="font"><?php the_title(); ?></h1></div>
            <div class="post_content">
            <form id="contactform" method="post" action="">
            <fieldset id="contactleft">
                            <label for="name" class="font">name:</label>
                            <input id="name" name="name" type="text" class="validate[required,custom[onlyLetter],length[0,100]]"/>
                            <br />
                            <label for="subject" class="font">subject:</label>
                            <input id="subject" name="subject" type="text"  class="validate[required,length[0,100]]"/>
                            <br />
                            <label for="phone" class="font">phone number:</label>
                            <input id="phone" name="phone" type="text"  class="validate[required,custom[onlyNumber],length[8,10]]" />
                            <br />
                            <label for="email" class="font">email:</label>
                            <input id="email" name="email" type="text"  class="validate[required,custom[email],length[0,50]]" />
             <fieldset id="contactright">
                            <label for="comments" class="font">comments:</label>
                            <textarea id="comments" name="comments" rows="5" cols="5" class="validate[required]"></textarea>
                            <input type="submit" value="Send It!" class="submit_btn font" />
            <?php the_post(); ?>
            <?php the_content(); ?>
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    Here is my code at the top of the header file

    	if(isset($_POST['name'])) {
        $email_to = "me@chrisando.com";
        $email_subject = "LOTR Contact Form";
    	 // validation expected data exists
        if(!isset($_POST['name']) ||
            !isset($_POST['subject']) ||
            !isset($_POST['phone']) ||
            !isset($_POST['email']) ||
            !isset($_POST['comments']) ) {
        $name = $_POST['name']; // required
        $organisation = $_POST['subject']; // required
        $phone = $_POST['phone']; // required
        $email = $_POST['email']; // not required
        $comments = $_POST['comments']; // required
        $email_message = "LOTR Contact Form.\n\n";
        function clean_string($string) {
          $bad = array("content-type","bcc:","to:","cc:","href");
          return str_replace($bad,"",$string);
        $email_message .= "Name: ".clean_string($name)."\n";
        $email_message .= "subject: ".clean_string($organisation)."\n";
        $email_message .= "Phone: ".clean_string($phone)."\n";
        $email_message .= "Email: ".clean_string($email)."\n";
        $email_message .= "Comments: ".clean_string($comments)."\n";
    	// create email headers
    	$headers = 'From:'.$email."\r\n".
    	'Reply-To: '.$email."\r\n" .
    	'X-Mailer: PHP/' . phpversion();
    	$ret = @mail($email_to, $email_subject, $email_message, $headers);
    	setcookie("seeMeOnce", $ret);
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    Looking forward to some troubleshooting tips!

  2. chrisando
    Posted 4 years ago #

    any ideas?

Topic Closed

This topic has been closed to new replies.

About this Topic