treehouse : what would you like to learn today?
Web Design Web Development iOS Development

php autoresponder problem

  • Hi,
    I'm creating my first php mail script from a form I created, and so far so good. I am able to get the form results emailed to me, but I can't make it send a response to the form submitter. Do I have it setup wrong? The first mail line (form submit) is working, just the second one (autorespond) is not...?! Any help is greatly appreciated!
    Here's my code: (links are just example links)

    <?php

    $name = $_REQUEST['name'] ;
    $phone= $_REQUEST ['phone'];
    $address= $_REQUEST ['address'];
    $fax= $_REQUEST ['fax'];
    $email= $_REQUEST ['email'];

    $message = \"Name: $name\n\n\";
    $message .= \"Phone: $phone\n\n\";
    $message .= \"Address: $address\n\n\";
    $message .= \"Fax: $fax\n\n\";
    $message .= \"Email: $email\n\n\";

    $reply = \"My auto respond message, thank you, blah blah.\";

    if (!isset($_REQUEST['name']))
    header( \"Location: http://www.mysite.com/test/orderform.html\" );

    elseif (empty($name) || empty($phone) || empty($email)) {
    header( \"Location: http://www.mysite.com/error.html\" );
    }

    else {
    mail( \"info@mysite.com\", \"Submitted Order Form\", $message, \"From: $email\" );
    mail( \"$email\", \"Order Confirmation\", $reply, \"From: MySite\" );
    header( \"Location: http://www.mysite.com/thankyou.html\" );
    }

    ?>
  • I don't thin that the $email should be in quotations.
    mail( $email, \"Order Confirmation\", $reply, \"From: MySite\" );

    Try this.
  • Also this looks weird:


    $_REQUEST ['email'];


    maybe you need to remove the spaces in the request like this:


    $_REQUEST['email'];