Question : How do I send a thank you email to the registrant?

I have my form set up to email its information to someone internally but I would also like to send a thank you email to the person that submitted the form. How do I do this? Below is what I have so far.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
<?php
	if($_POST)
	   {
		$FirstName = $_POST['fName'];
		$LasttName = $_POST['lName'];
		$Email = $_POST['email'];
		$Address = $_POST['address1'];
		$City = $_POST['city'];
		$State = $_POST['state'];
		$Zip = $_POST['zip'];
		$Phone = $_POST['phone'];
		$Fax = $_POST['fax'];

		$StrEmail = "<html><body>";
		$StrEmail =  $StrEmail."<B> First Name : </B> ".$FirstName ."<BR>";
		$StrEmail =  $StrEmail. "<B> Last Name : </B>" .$LasttName ."<BR>";
		$StrEmail =  $StrEmail. "<B> Email : </B>" . $Email ." <BR>" ;
		$StrEmail =  $StrEmail. "<B> Address : </B> " . $Address . "<BR>";
		$StrEmail =  $StrEmail. "<B> City : </B> " . $City . "<BR>";
		$StrEmail =  $StrEmail. "<B> State : </B> " . $State . "<BR>";
		$StrEmail =  $StrEmail. "<B> Zip : </B>" .$Zip."<BR>" ;
		$StrEmail =  $StrEmail. "<B> Phone : </B>" .$Phone."<BR>" ;
		$StrEmail =  $StrEmail. "<B> Fax : </B>" .$Fax."<BR><BR>" ;
		$StrEmail =  $StrEmail. "</body></html>";


		$to = '[email protected]';
		$subject = 'Wine Order';
		$headers  = "From: [email protected]\r\nReply-To: [email protected]";
		$headers .= 'MIME-Version: 1.0' . "\r\n";
		$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
		
		$mail_sent = @mail( $to, $subject, $StrEmail, $headers );
		
		
		header("Location: http://www.somewhere.com/thank_you.html");

	}

?>

Answer : How do I send a thank you email to the registrant?

I like your last idea - let them print the page.  You're much safer with that.  But you still need to be careful about what you store in your data base.  Learn about escaping the data, base64 encoding, etc.

Data filtering is somewhat facilitated by the PHP function filter_var() however it is a general purpose solution and you have some very specific needs here.  This is the way to filter a telephone number in the USA.  There are undoubtedly other examples you might want to look for.  One good way to filter an address is to call the Yahoo Geocoder.  It can tell you if the address is real and will return a normalized address.

The better job you do of controlling the input data, the better your chances that your application will not suddenly fail.  The mantra is and always will be "Accept Only Known Good Values."

Ciao, bella, ~Ray
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
<?php // RAY_phone_numbers.php - USING USA PHONE NUMBERS
error_reporting(E_ALL);

// A FUNCTION TO VALIDATE A PHONE NUMBER AND RETURN A NORMALIZED STRING
// MAN PAGE: http://discuss.fogcreek.com/joelonsoftware3/default.asp?cmd=show&ixPost=102667&ixReplies=15
function strtophone($phone, $format=FALSE, $dlm='-')
{
    // TRANSLATE INPUT LIKE 1-800-BIG-DOGS
    $phone = strtoupper($phone);
    if (preg_match('/[A-Z]/', $phone))
    {
        $phone = str_replace('A', '2', $phone);
        $phone = str_replace('B', '2', $phone);
        $phone = str_replace('C', '2', $phone);

        $phone = str_replace('D', '3', $phone);
        $phone = str_replace('E', '3', $phone);
        $phone = str_replace('F', '3', $phone);

        $phone = str_replace('G', '4', $phone);
        $phone = str_replace('H', '4', $phone);
        $phone = str_replace('I', '4', $phone);

        $phone = str_replace('J', '5', $phone);
        $phone = str_replace('K', '5', $phone);
        $phone = str_replace('L', '5', $phone);

        $phone = str_replace('M', '6', $phone);
        $phone = str_replace('N', '6', $phone);
        $phone = str_replace('O', '6', $phone);

        $phone = str_replace('P', '7', $phone);
        $phone = str_replace('Q', '7', $phone);
        $phone = str_replace('R', '7', $phone);
        $phone = str_replace('S', '7', $phone);

        $phone = str_replace('T', '8', $phone);
        $phone = str_replace('U', '8', $phone);
        $phone = str_replace('V', '8', $phone);

        $phone = str_replace('W', '9', $phone);
        $phone = str_replace('X', '9', $phone);
        $phone = str_replace('Y', '9', $phone);
        $phone = str_replace('Z', '9', $phone);
    }

    // DISCARD NON-NUMERIC CHARACTERS
    $phone = preg_replace('/[^0-9]/', '', $phone);

    // DISCARD A LEADING '1' FROM NUMBERS ENTERED LIKE 1-800-555-1212
    if (substr($phone,0,1) == '1') $phone = substr($phone,1);

    // IF LESS THAN TEN DIGITS, IT IS INVALID
    if (strlen($phone) < 10) return FALSE;

    // IF IT STARTS WITH '0' OR '1' IT IS INVALID, SECOND DIGIT CANNOT BE '9' (YET)
    if (substr($phone,0,1) == '0') return FALSE;
    if (substr($phone,0,1) == '1') return FALSE;
    if (substr($phone,1,1) == '9') return FALSE;

    // ISOLATE THE COMPONENTS OF THE PHONE NUMBER
    $ac = substr($phone,0,3); // AREA
    $ex = substr($phone,3,3); // EXCHANGE
    $nm = substr($phone,6,4); // NUMBER
    $xt = substr($phone,10);  // EXTENSION

    // ADD OTHER TESTS HERE AS MAY BE NEEDED - THESE ARE FOR LOCAL APPS
    if ($ac == '900') return FALSE;
    if ($ac == '976') return FALSE;
    if ($ex == '555') return FALSE;

    // IF NOT FORMATTED
    if (!$format) return $phone;

    // STANDARDIZE THE PRINTABLE FORMAT OF THE PHONE NUMBER LIKE 212-555-1212-1234
    $formatted_phone = $ac . $dlm . $ex . $dlm . $nm;
    if ($xt != '') $formatted_phone .= $dlm . $xt;
    return $formatted_phone;
}



// DEMONSTRATION OF THE FUNCTION IN ACTION.  IF ANYTHING IS POSTED?
if (!empty($_POST["phone"]))
{

    // VALIDATE PHONE USING FUNCTION ABOVE
    if (!$phone = strtophone($_POST["phone"], TRUE))
    {
        // FUNCTION RETURNS FALSE IF PHONE NUMBER IS UNUSABLE
        echo "BOGUS: {$_POST["phone"]} \n";
    }
    else
    {
        // SHOW THE FORMATTED PHONE
        echo "VALID: $phone\n";
    }
}


// END PHP, PUT UP THE FORM TO TEST PHONE NUMBERS
?>
<form method="post">
ENTER A PHONE NUMBER:
<input name="phone" /><br/>
<input type="submit" />
</form>
TRY SOME OF THESE (COPY AND PASTE):
<br/>1-800-5551212
<br/>202-537-7560
<br/>123456789
<br/>703-356-5300 x2048
<br/>(212) 555-1212
<br/>1 + (212) 555-1212
<br/>1 (292) 226-7000
Random Solutions  
 
programming4us programming4us