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 4 of 4

Thread: Php form mail.

  1. #1
    New to the CF scene
    Join Date
    Jan 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Php form mail.

    Hi all... and firstly let me apologise for my newbieness

    I am building a site for a friend at www.oldcastlehotel.co.uk

    I have built a form (basic but all thats needed)

    when it comes to the form handler I have a file called mail.php which the enquire.htm file calls on when the form is submitted.

    this is the original form..

    <?
    $to = 'me@mydomain.com';
    $subject = 'subject';
    $message = 'From: ' . $_REQUEST['name'] . "\n\n" . $_REQUEST['data'];
    $email = $_REQUEST['email'];
    $headers = 'From: ' . $email . "\r\n" .
    'Reply-To: ' . $email . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

    mail ($to, $subject, $message, $headers);
    header("Location: thanks.html");
    ?>

    When this script is used the form works ok but not all the fields on the form are emailed.. all I get is the name, email and the first option.

    All I want to do is add the form fields which are data1, data2, data3 and data4 to the php side and I am struggling a bit.

    I am new to php... but wanna learn. Any help from anyone? please!

    John

  2. #2
    Supreme Master coder!
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    10,125
    Thanks
    10
    Thanked 1,162 Times in 1,153 Posts
    You're missing some of the form variables ...
    Plus ... $_REQUEST should no longer be used ...

    PHP Code:
    <?
    $to 
    'me@mydomain.com';
    $subject 'subject';
    $contact $_POST['data1'];
    $enquiry $_POST['data'];
    $dates $_POST['data3'];
    $text $_POST['data4'];
    $email $_POST['email'];

    $message "From: " $contact "\n\n" 
    "Enquiry:" $enquiry ."\n\n"
    "Dates:" $dates ."\n\n"
    "Text:" $text ."\n\n";

    $headers "From: " $email "\r\n" .
    "Reply-To: " $email "\r\n" .
    "X-Mailer: PHP/" phpversion();

    mail ($to$subject$message$headers);
    header("Location: thanks.html");
    ?>

  3. #3
    New to the CF scene
    Join Date
    Jan 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Cheers for that... I have been playing some more and got this php script.

    <?
    $to = 'johnzo@live.co.uk';
    $subject = 'subject';
    $contact = $_POST['name'];
    $telephone = $_POST['number'];
    $enqtype = $_POST['enqtype'];
    $dates = $_POST['dates'];
    $other = $_POST['Otherinfo'];
    $email = $_POST['email'];

    $message = "From: " . $contact . "\n\n"
    . "Enquiry:" . $enquiry ."\n\n"
    . "Dates:" . $dates ."\n\n"
    . "Text:" . $text ."\n\n"
    . "Other:" . $other ."\n\n";

    $headers = "From: " . $email . "\r\n" .
    "Reply-To: " . $email . "\r\n" .
    "X-Mailer: PHP/" . phpversion();

    mail ($to, $subject, $message, $headers);
    header("Location: thanks.html");
    ?>

    But the email comes back when its filled in on the site as...

    From: Warby

    Enquiry:

    Dates:

    Text:

    all the out puts are blank... any ideas.. sorry for being stupid

  4. #4
    New to the CF scene
    Join Date
    Jan 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    THANK YOU MY FRIEND!

    All sorted out now

    cheers again
    Last edited by maverick4546; 01-14-2010 at 12:22 AM.


 

Posting Permissions

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