www.webdeveloper.com
Results 1 to 3 of 3

Thread: Contact form - get an empty email (no data)

Hybrid View

  1. #1
    Join Date
    May 2008
    Posts
    9

    Contact form - get an empty email (no data)

    Hi Folks,

    I am not too familiar with PHP but did manage to get a simple contact form together but while the data seems to get submitted okay, the email I get in empty and comes from 'INVALID_ADDRESS@.SYNTAX-ERROR.' which puzzles me very much...!

    The other thing I would like to implement is a redirection to a web page after users submit the form.

    Any help/tips would be much appreciated!

    You can see the form (html) here - http://www.lalydesign.co.uk/organics...ntact_test.php

    And this is the PHP code (send_contact.php) I am using to process the data

    <?php
    // Contact subject
    $subject
    ="$subject";
    // Details
    $message="$detail";
    // Mail of sender
    $mail_from="$customer_mail";
    // From
    $header="from:
    $name <$mail_from>";
    // Enter your email address
    $to
    ='pierrick419@yahoo.co.uk';
    $send_contact=mail($to,$subject,$message,$header);
    // Check, if message sent to your email

    if($send_contact){
    echo "We've received your contact information";
    }
    else {
    echo "ERROR";
    }
    ?>

    Cheers

    P

  2. #2
    Join Date
    May 2008
    Posts
    9
    I figured out the issue above and thought I'd share it

    Here is the corrected code for 'send_contact.php'

    <?php
    // Contact subject
    $subject = $_POST['subject'];
    // Details
    $message = $_POST['detail'];
    // Mail of sender
    $mail_from = $_POST['customer_mail'];
    // From
    $header = "from: $name <$mail_from>";
    // Enter your email address
    $to = 'youremail@something.co.uk';
    $send_contact = mail($to,$subject,$message,$header);
    // Check, if message sent to your email

    if($send_contact){
    echo "We've received your contact information";
    }
    else {
    echo "ERROR";
    }
    ?>

    Enjoy

  3. #3
    Join Date
    Nov 2008
    Posts
    2,477
    You need to be cleaning and validating user input before using it like this.
    The first rule of Tautology Club is the first rule of Tautology Club.

Thread Information

Users Browsing this Thread

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

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
  •  
HTML5 Development Center



Recent Articles