The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> How do you make the Submit button on a form send the customer an email?
kbed1138
post Mar 24 2015, 03:27 PM
Post #1





Group: Members
Posts: 6
Joined: 23-March 15
Member No.: 22,414



I made a form for the company i work for. I got it all working correctly, and when the customer hits the Submit button, it takes them to a page that says "thank you for your order". I want to have an E-mail sent off to the customer as well, with a summary of there order, such as what they ordered and a time frame of when they can expect it to arrive, etc. Can this be done with PHP? I'm not much of a web designer, and don't know where to begin to get this to work. Thanks in advance.

the PHP Code i currently have is:
CODE
  
<?php

/* Subject and email Variables    */

    $emailSubject = 'Key Order';
    $webMaster = 'keyorder@homakmfg.com';
    
/* Gathering Data Variables*/

    $dateField = $_POST['Date'];
    $firstnameField = $_POST['FirstName'];
    $lastnameField = $_POST['LastName'];
    $addressoneField = $_POST['AddressOne'];
    $addresstwoField = $_POST['AddressTwo'];
    $cityField = $_POST['City'];
    $stateField = $_POST['State'];
    $zippostalcodeField = $_POST['ZipPostalCode'];
    $countryField = $_POST['Country'];
    $phonenumberField = $_POST['PhoneNumber'];
    $emailField = $_POST['Email'];
    $creditcardField = $_POST['CreditCard'];
    $cardnumberField = $_POST['CardNumber'];
    $expirationField = $_POST['ExpirationDate'];
    $itemoneField = $_POST['ItemOne'];
    $keycodeoneField = $_POST['KeycodeOne'];
    $specialinstructionsoneField = $_POST['SpecialInstructionsOne'];
    $itemtwoField = $_POST['ItemTwo'];
    $keycodetwoField = $_POST['KeycodeTwo'];
    $specialinstructionstwoField = $_POST['SpecialInstructionsTwo'];
    $itemthreeField = $_POST['ItemThree'];
    $keycodethreeField = $_POST['KeycodeThree'];
    $specialinstructionsthreeField = $_POST['SpecialInstructionsThree'];
    
    $body = <<<EOD
<br><hr><br>
Date: $dateField <br/>
First Name: $firstnameField <br>
Last Name: $lastnameField <br>
Address Line One: $addressoneField <br>
Address Line Two: $addresstwoField <br>
City: $cityField <br>
State: $stateField <br>
Zip Code: $zippostalcodeField <br>
Country: $countryField <br>
Phone: $phonenumberField <br>
Email: $emailField <br>
Credit Card: $creditcardField <br>
Card Number: $cardnumberField <br>
Expiration Date: $expirationField <br>
Item One: $itemoneField <br>
Key Code One: $keycodeoneField <br>
Special Instructions: $specialinstructionsoneField <br>
Item Two: $itemtwoField <br>
Key Code Two: $keycodetwoField <br>
Special Instructions Two: $specialinstructionstwoField <br>
Item Three: $itemthreeField <br>
Key Code Three: $keycodethreeField <br>
Special Instructions Three: $specialinstructionsthreeField <br>
EOD;

    $headers = "From: $emailField\r\n";
    $headers .= "Content-type: text/html\r\n";
    $success = mail($webMaster, $emailSubject, $body, $headers);
    
/* Results Rendered as Html*/
    
    $theResults = <<<EOD
Thank you for your Order!
EOD;
echo "$theResults";
    
?>
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Mar 24 2015, 05:45 PM
Post #2


.
********

Group: WDG Moderators
Posts: 9,656
Joined: 10-August 06
Member No.: 7



Doesn't the script above already send an email and print the text "Thank you for your Order!"?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Mar 29 2015, 08:12 PM
Post #3


.
********

Group: WDG Moderators
Posts: 9,656
Joined: 10-August 06
Member No.: 7



QUOTE(masonh928 @ Mar 30 2015, 02:42 AM) *

Don't put quote marks on vars.

Why not, if it's doublequotes? Unless you meant this part:

CODE
echo "$theResults";

where it seems unnecessary (but not an error).

QUOTE
Sanitize data, with HTMLspecialchars();

True, at least if it's an HTML email. But in that case it probably needs more HTML than just the BR elements in the example above (not sure of the details).

QUOTE
and yes, just make a new mail query like such.

Oh, the script should send two emails, one to the company and one to the customer? I missed that part before.

User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 24th April 2024 - 07:52 PM