Contact form - get an empty email (no data)

Discussion in 'PHP' started by pierrick419, May 28, 2010.

  1. #1
    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/organicspirit-1/contact_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
     
    pierrick419, May 28, 2010 IP
  2. MyVodaFone

    MyVodaFone Well-Known Member

    Messages:
    1,048
    Likes Received:
    42
    Best Answers:
    10
    Trophy Points:
    195
    #2
    Shouldn't it be something like

    
    <?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 = '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";
    }
    ?>
    
    PHP:
    Untested but basically your send_contact.php file needs to get the details from the form so you use $_POST['xxxxxx']
     
    MyVodaFone, May 28, 2010 IP
  3. pierrick419

    pierrick419 Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Brilliant. It works fine. Thank you very much for your quick response.
    P
     
    pierrick419, May 28, 2010 IP