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

Thread: contact us form

  1. #1
    New to the CF scene
    Join Date
    Oct 2012
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    contact us form

    sir i have writtn code for writing contact us form. its working bt mail is not sending
    plz chk the error
    PHP Code:
    <?

    /************************
    * Variables you can change
    *************************/

    $mailto "youremail@email.com";
    $cc "";
    $bcc "";
    $subject "Email subject";
    $vname "BrightCherry enquiry";


    /************************
    * do not modify anything below unless you know PHP/HTML/XHTML
    *************************/


    $email $_POST['email'];

    function 
    validateEmail($email)
    {
       if(
    eregi('^[a-zA-Z0-9._-]+@[a-zA-Z0-9-]+\.[a-zA-Z]{2,4}(\.[a-zA-Z]{2,3})?(\.[a-zA-Z]{2,3})?$'$email))
          return 
    true;
       else
          return 
    false;
    }


    if((
    strlen($_POST['name']) < ) || (strlen($email) < ) || (strlen($_POST['message']) < ) || validateEmail($email) == FALSE){
        
    $emailerror .= '';

        if(
    strlen($_POST['name']) < ){
            
    $emailerror .= '<li>Enter name</li>';
        }

        if(
    strlen($email) < ){
            
    $emailerror .= '<li>Enter email</li>';
        }

        if(
    validateEmail($email) == FALSE) {
            
    $emailerror .= '<li>Enter valid email</li>';
        }

        if(
    strlen($_POST['message']) < ){
            
    $emailerror .= '<li>Enter message</li>';
        }

    } else {

        
    $emailerror .= "Your email has been sent successfully";



        
    // NOW SEND THE ENQUIRY

        
    $timestamp date("F j, Y, g:ia");

        
    $messageproper ="\n\n" .
            
    "Name: " .
            
    ucwords($_POST['name']) .
            
    "\n" .
            
    "Email: " .
            
    ucwords($email) .
            
    "\n" .
            
    "Website: " .
            
    ucwords($_POST['website']) .
            
    "\n" .
            
    "Company: " .
            
    ucwords($_POST['company']) .
            
    "\n" .
            
    "Comments: " .
            
    $_POST['message'] .
            
    "\n" .
            
    "\n\n" ;

            
    $messageproper trim(stripslashes($messageproper));
            
    mail($mailto$subject$messageproper"From: \"$vname\" <".$_POST['e_mail'].">\nReply-To: \"".ucwords($_POST['first_name'])."\" <".$_POST['e_mail'].">\nX-Mailer: PHP/" phpversion() );

    }
    ?>

    <div id='emailerror'>
        <ul>
            <? echo $emailerror?>
        </ul>
    </div>

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    These headers should be separated with \r\n, not with \n.
    What is the result of the mail() call? Does it return true or false?


  •  

    Posting Permissions

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