Results 1 to 3 of 3

Thread: I'm getting blank emails using php contact forms

  1. #1

    I'm getting blank emails using php contact forms

    Hey guys,

    Got bit of a dilemma. I've created a form in php for my website,
    somehow i'm getting blank emails every 2 or 3 weeks. The form works
    great when people enter data but at times, I just receive nothing. I
    tested the form on different computers to confirm it works. Here is
    what I have done on the html contact form. I've used the built in
    javascript dreamweaver cs4 validation for the fields and used captcha
    for a layer of security (it saved as contact.php). Now here is the php
    code.

    PHP Code:
    <?php
                   $errors 
    = array();
             
             if(empty(
    $_POST['name'])){
                
    $errors[] = 'Please enter your name';
                
             } else {
                
                echo  
    "";
             }
             
             
             if(empty(
    $_POST['email'])){
                
    $errors[] = 'Please enter your email';
                
             } else {
                
                echo 
    "";
                
             }
             
             if(empty(
    $_POST['comments'])){
                
    $errors[] = 'Please enter your comments';
                
             } else {
                echo  
    "";
             }
                
                
                
    $emailPattern '/^[^@\s]+@([-a-z0-9]+\.)+[a-z]{2,}$/i';
       
               
    $to "fake@email.com";
       
       
             
    $subject 'whaaaat?';
             
    $from 'whoever';
             
          
             
             
             
    $name =  safe (stripslashes$_POST['name']) );
             
    $email =  safe($_POST['email'] );
             
    $phone safe($_POST['phone'] );
             
    $reasons =  safe ($_POST['reasons']);
             
    $search =  safe$_POST['search']);
             
    $facebook safe($_POST['facebook'] );
             
    $wsb =  safe $_POST['wsb']);
             
    $other =  safe$_POST['other']);
             
    $comments safe(stripslashes($_POST['comments']) );
             
             
             
    $headers "From: "$from "<" $to">\r\n";  
             
    $headers .= "Reply-To: " $email "\r\n"
             
    $headers .= "Return-path: "$email;
             

               
    $message .= "Name:  " $name "\n";
             
    $message .= "Email: " $email "\n\n";
             
    $message .= "Phone Number: " $number "\n\n\n";
             
    $message .= "Reasons:  " $reasons "\n\n\n\n";
             
    $message .= "Facebook: " $facebook "\n\n\n\n\n";;
             
    $message .= "WSB-TV: " $wsb "\n\n\n\n\n\n";
             
    $message .= "Other: " $other "\n\n\n\n\n\n\n";
             
    $message .= "Comments: " $comments "\n\n\n\n\n\n\n\n";
             
             if (
    mail($to,$subject,$message,$headers)){ 
             
            echo 
    "Thank you so much for your Inquiry. I'm looking forward in serving you soon!"
          } else { 
            echo 
    "&Result=error"
          } 
       
       function 
    safe($string
       { 
          
    $pattern "/\r|\n|\%0a|\%0d|Content\-Type:|bcc:|to:|cc:/i"
          return 
    preg_replace($pattern''$string); 
       }

            
    ?>
    Please help and thanks in advanced!

  2. #2
    change
    PHP Code:
    if (mail($to,$subject,$message,$headers)){ 
             
            echo 
    "Thank you so much for your Inquiry. I'm looking forward in serving you soon!"
          } else { 
            echo 
    "&Result=error"
          } 
    to
    PHP Code:
    if (count($errors) < 1){ 
            
    mail($to,$subject,$message,$headers);
            echo 
    "Thank you so much for your Inquiry. I'm looking forward in serving you soon!"
          } else { 
            echo 
    "&Result=error"
          } 
    Let us live so that when we come to die even the undertaker will be sorry. - Mark Twain
    Don't PM me your CSS, xHTML, JS or PHP questions. I will not reply to ANY IE6 questions.

  3. #3
    Much appreciated!


    Quote Originally Posted by simplistik View Post
    change
    PHP Code:
    if (mail($to,$subject,$message,$headers)){ 
             
            echo 
    "Thank you so much for your Inquiry. I'm looking forward in serving you soon!"
          } else { 
            echo 
    "&Result=error"
          } 
    to
    PHP Code:
    if (count($errors) < 1){ 
            
    mail($to,$subject,$message,$headers);
            echo 
    "Thank you so much for your Inquiry. I'm looking forward in serving you soon!"
          } else { 
            echo 
    "&Result=error"
          } 

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012