SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: blank emails

  1. #1
    SitePoint Member
    Join Date
    Sep 2011
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    blank emails

    I have contact forms on my site and they are in PHP. Almost every day I receive blank email from the forms. I do not understand why this happens because each form has a filter that requires each field to be filled before the user can click "submit".

    Below is a copy of the code of one of the PHP fields and the link to my site. Can any one point me in the right direction?
    Thank you,
    Lee

    http://www.masterfranchises.org/choc...-franchise.htm

    <?PHP
    // grab the information from the form
    $check = false;
    $site = "Chockfull o' Nuts Coffee";
    $fname = $_POST['FirstName'];
    $lname = $_POST['LastName'];
    $email = $_POST['Email'];
    $wphone = $_POST['WorkPhoneExt'];
    $hphone = $_POST['HomePhone'];
    $mphone = $_POST['MobilePhone'];
    $address =($_POST['StreetAddress']);
    $city =($_POST['City']);
    $country =($_POST['country']);
    $state =($_POST['State']);
    $zipcode =($_POST['PostalCode']);
    $time = $_POST['time'];
    $liquid = $_POST['liquid'];
    $net = ($_POST['net']);
    $contact_time = ($_POST['BestTimeToContact']);
    $brokersname = ($_POST['BrokersName']);
    $invalid = false;
    //Validate information
    if( (empty($fname)) || (empty($lname)) || (empty($email)) || (empty($hphone)) ){
    echo "<font color=red face=Arial size=4>You have not entered the required fields, please complete the form to recieve more information about $site Franchises.<p><i><font color=navy>This page will automatically refresh. ";
    echo "<META HTTP-EQUIV='Refresh'
    CONTENT='3; URL=\'>";
    $invalid = true;
    }

    // mail user their information

    $subject = "Lead Information from $site";
    $message = "

    Lead Information Generated By Master Franchise Specialists:

    Name: $lname, $fname
    Franchise: $site
    E-mail: $email
    Home Phone: $hphone
    Work Phone: $wphone
    Mobile Phone: $mphone
    Address: $address
    City: $city
    Country: $country
    State: $state
    ZipCode: $zipcode
    Liquid Capital: $liquid
    Net Worth: $net
    Timeframe: $time
    Best Contact Time: $contact_time
    Broker's Name: $brokersname

    Your Lead for: $lname, $fname has been recorded.


    Management Solutions Provided By: Master Franchise Specialists

    ";


    $admin="ehiweb@gmail.com";

    mail($admin, $subject, $message);
    if ( $check = true )
    {
    //mail("customerservice@masterfranchises.org", $subject, $message);
    mail("franmaster@sbcglobal.net", $subject, $message);
    mail("elisandro@hotmail.com", $subject, $message);
    }
    if(!$invalid){
    echo "<META HTTP-EQUIV='Refresh'
    CONTENT='2; URL=index.htm'>";
    echo"<font face=Arial size=3 color=navy>Thank you for your submission, your information will be processed as soon as possible. You will be redirected in 5 seconds.";
    }
    ?>

  2. #2
    SitePoint Member
    Join Date
    Sep 2011
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    function mail_control($email) { 
     
        if (!
    eregi("^[^@]{1,64}@[^@]{1,255}$"$email)) { 
            return 
    false
        } 

        
    $email_array explode("@"$email); 
        
    $local_array explode("."$email_array[0]); 
        
        for (
    $i 0$i sizeof($local_array); $i++) { 
            if (!
    eregi("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$"$local_array[$i])) { 
            return 
    false
            } 
        }   
        if (!
    eregi("^\[?[0-9\.]+\]?$"$email_array[1])) { // Check if domain is IP. If not, it should be valid domain name 
            
    $domain_array explode("."$email_array[1]); 
            if (
    sizeof($domain_array) < 2) { 
            return 
    false// Not enough parts to domain 
            

            for (
    $i 0$i sizeof($domain_array); $i++) { 
                if (!
    eregi("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$"$domain_array[$i])) { 
                return 
    false
                } 
            } 
        } 
    return 
    true

    You can use this function. You will give up e-mail parameters. İf your e-mail is validating, returning true at this function.

    Easy come.

  3. #3
    SitePoint Addict
    Join Date
    Apr 2011
    Posts
    266
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Hi,
    Try remove the:
    mail($admin, $subject, $message);

    Then replace the:
    if ( $check = false ) {...}
    With:
    if ( $invalid === true ) {
    mail($admin, $subject, $message);
    }
    Free: Web Programming Courses HTML, CSS, Flash
    Web Programming: AJAX Course and PHP-MySQL Course video Lessons
    Good JavaScript and jQuery course for beginners

  4. #4
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,747
    Mentioned
    65 Post(s)
    Tagged
    0 Thread(s)
    You're validating at the Javascript level, but not the PHP level.

    throw this up top.

    PHP Code:
    if(!isset($_POST['FirstName'])) { die(); } 
    5$ says the blank email you get every day is a search engine crawling over your email page.

  5. #5
    SitePoint Member
    Join Date
    Sep 2011
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by MarPlo View Post
    Hi,
    Try remove the:
    mail($admin, $subject, $message);

    Then replace the:
    if ( $check = false ) {...}
    With:
    if ( $invalid === true ) {
    mail($admin, $subject, $message);
    }
    This function should use the following as:

    PHP Code:
    <?php
    if(mail_control("name@domain.com")==true){
    // Your actions...
    }
    else
    {
    echo 
    'Please enter a valid email address.';
    }
    ?>
    I can't see error in your mail function. Use came to be incorrect.


Bookmarks

Posting Permissions

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