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
    Jan 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Contact Form Sending With No Field Data

    I have created a contact form for a client's website. The purpose of this form is for visitors to enter some information about themselves and once they press submit, my client receives the information via email. However, the form is being submitted without any information coming through. Just emails with no contents.

    Why is the contents not being sent through? I would really appreciate some guidance!

    Please see my code below:

    Code:
    <?php
    /*
    This first bit sets the email address that you want the form to be submitted to.
    You will need to change this value to a valid email address that you can access.
    */
    $webmaster_email = "me@email.com";
    
    /*
    This bit sets the URLs of the supporting pages.
    If you change the names of any of the pages, you will need to change the values here.
    */
    $feedback_page = "questionnaire1.html";
    $error_page = "error_message.html";
    $thankyou_page = "thank_you.html";
    
    /*
    This next bit loads the form field data into variables.
    If you add a form field, you will need to add it here.
    */
    $email_address = $_REQUEST['email_address'] ;
    $name = $_REQUEST['name'] ;
    $telephone = $_REQUEST['telephone'] ;
    $brand = $_REQUEST['brand'] ;
    $target_demo = $_REQUEST['target_demo'] ;
    $describe_product = $_REQUEST['describe_product'] ;
    
    /*
    The following function checks for email injection.
    Specifically, it checks for carriage returns - typically used by spammers to inject a CC list.
    */
    function isInjected($str) {
    	$injections = array('(\n+)',
    	'(\r+)',
    	'(\t+)',
    	'(%0A+)',
    	'(%0D+)',
    	'(%08+)',
    	'(%09+)'
    	);
    	$inject = join('|', $injections);
    	$inject = "/$inject/i";
    	if(preg_match($inject,$str)) {
    		return true;
    	}
    	else {
    		return false;
    	}
    }
    
    // If the user tries to access this script directly, redirect them to the feedback form,
    if (!isset($_REQUEST['email_address'])) {
    header( "Location: $feedback_page" );
    }
    
    // If the form fields are empty, redirect to the error page.
    elseif (empty($email_address) || empty($target_demo) || empty($describe_product) || empty($telephone) || empty($brand) || empty($name)) {
    header( "Location: $error_page" );
    }
    
    // If email injection is detected, redirect to the error page.
    elseif ( isInjected($email_address) ) {
    header( "Location: $error_page" );
    }
    
    
    // If we passed all previous tests, send the email then redirect to the thank you page.
    else {
    mail( "me@email.com", "Client Questionnaire",
      "From: $email_address" );
    
    
    header( "Location: $thankyou_page" );
    }
    ?>

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,307
    Thanks
    23
    Thanked 612 Times in 611 Posts
    Instead of reinventing the wheel maybe an existing code will do the job for you?
    http://www.freecontactform.com/email_form.php


  •  

    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
    •