Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Sep 2012
    Posts
    9
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Exclamation Contact Form Not Working Properly

    The contact form on my site is not working properly. After the user submits the form, I do not receive an email response nor' are they redirected to my reply page.

    Any suggestions?

    Contact Code form:
    Code:
    <!-- Contact Form Begins -->
    
    <?php
    
    include ('header-html5.php');
    
    ?>
    
    <form class="contact_form" action="a-comments.php" method="post" id="comments">
    <br>
          
    <label for="name" class="fontcolor">Your Name*</label>
    <br><br>
    
    <input type="text" id="name" placeholder="John Doe" required />
    <br><br>
    
    <label for="email" class="fontcolor">Your Email Address*</label> 
    <br><br>
    
    <input type="email" id="email" name="email" placeholder="john_doe@example.com" required />
    <br><br>
                
    <label for="subject" class="fontcolor">Subject*</label>  
    <br><br>
    
    <input type="text" id="subject" placeholder="John Doe" required />
    <br><br>
     
    <label for="message" class="fontcolor">Message*</label>
    <br><br>
    
    <textarea name="message" id="message" cols="60" rows="15" required ></textarea>
    <br><br>
                
    <label for="antispam" class="fontcolor">Anti-Spam (14 + 6)*</label>
    <br><br>
    
    <input name="addition" id="formStyleInsert" placeholder="14+6" required />
    <br><br>
    
    <button class="submit" type="submit" id="submit" value="SEND">Send</button> 
    
    </form><!-- Contact Form Ends -->

    Sever-side PHP form

    Code:
    <?php
        $name = $_POST['name'];
        $email = $_POST['email'];
        $comments= $_POST['comments'];
    	$headers = "From: $email \r\n";
      	$to = 'kyhry.taylor@gmail.com'; 
        $subject = 'IMD110 - Form';
        $addition = $_POST['addition'];
    			
        $body = "From: $name\n E-Mail: $email\n Comments:\n $comments";
    			
     if ($_POST['submit'] && $addition == '20') {				 
            if (mail ($to, $subject, $body, $headers)) { 
    	   header( "Location:a-commentsReply.php" );
    	
    	} else { 
    	    echo '<p>Something is incorrect, hit the back button and try again!</p>'; 
    	} 
        } else if ($_POST['submit'] && $addition!= '20') {
    	echo '<p>You answered the anti-spam question incorrectly hit the back button and try again!</p>';
        }
    ?>

    Reply Page PHP

    Code:
    <?php
    
    include ('header-html5.php');
    
    ?>
    
    <link href="html5Layout.css" rel="stylesheet" type="text/css">
    
    <section id="left2">
    <h2>Thank You for your comments
      <br> 
    </h2>
    If required I will be in touch with you shortly
    </section>
    
    <?php
    include('footer-html5.php');
    ?>

  • #2
    Regular Coder Arcticwarrio's Avatar
    Join Date
    May 2012
    Location
    UK
    Posts
    721
    Thanks
    20
    Thanked 84 Times in 84 Posts
    are you using phpmailer?

    http://phpmailer.worxware.com/
    There are 10 types of people on CodingForums,
    Those who understand Binary and those who dont.
    Get Cloud Hosting now from only£59 / month


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •