You need to be using PHP or a CGI program to do this for you. I would suggest the former provided your host has PHP enabled on your server.
Your form needs to point to the script:
<form method="post" action="thanks.php">
Then you need the folowing (this is the start of the file
thanks.php):
Code:
<?php
$fname = $_POST['fname'];
$lname = $_post['lname'];
$email = $_POST['email'];
$address = $_POST['address'];
$aptnum = $_POST['aptnum'];
$city = $_POST['city'];
$zip = $_POST['zip'];
$country = $_POST['country'];
$check = $_POST['check'];
if (!$check) { $check = "No"; } else { $check = "Yes"; }
$moneyorder = $_POST['moneyorder'];
if (!$moneyorder) { $moneyorder = "No"; } else { $moneyorder = "Yes"; }
$text = $_POST['question_text'];
$to = you@yourdomain.com;
$subject = "Results from online form";
$message = "First name: ".$fname."\nLast Name: ".$lname."\nEmail: ".$email."\nAddress: ".$address."\nApt# :".$aptnum."\nCity: ".$city."\nZip: ".$zip."\nCountry :".$country."\nPayment : Check - ".$check." or Moneyorder - ".$moneyorder."\nQuery: ".$text."\n";
$headers = "From: OnlineForm <you@yourdomain.com>\n";
mail($to, $subject, $message, $headers);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
.... rest of your thank you page
That should sort you out. However, you should check that the email address they have supplied is valid, and if it isn't, you should redirect the user back to the form whihc would then alos need to be a PHP page to make sense of the user being sent back.
To check the email address change the relevant part of the code above to:
Code:
$email = $_POST['email'];
if (!eregi ("^([a-z0-9_]|\\-|\\.)+@(([a-z0-9_]|\\-)+\\.)+[a-z]{2,4}$", $email)) {
header("Location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/form.php?err=email");
}
$address = $_POST['address'];
Now put your form on the page called form.php (though you can change this to suit so long as it has the .php suffix). Now that page should read:
Code:
<?php
$error = $_POST['err'];
if (!$error) { $error = 0; }
?>
<html>
<head>
<style type="text/css">
input.text {
font-family: verdana;
font-size: 10px;
border: solid black 1px;}
textarea {
font-family: verdana;
font-size: 10px;
border: solid black 1px;}
</style>
</head>
<body style="
scrollbar-base-color: 73BDBD;
scrollbar-track-color: white;
scrollbar-face-color: white;
scrollbar-highlight-color: white;
scrollbar-3dlight-color: 73BDBD;
scrollbar-darkshadow-color: white;
scrollbar-shadow-color: 73BDBD;
scrollbar-arrow-color: black;">
<?php
if ($error == "email") { echo "<span style=''color:red">The email address you entered did not conform to recognised standards.</span><br>; }
?>
<font face="verdana" size="1">
<form method="post" action="thanks.php">
First name:<br><input type="text" name="fname" class="text"><br>
Last name:<br><input type="text" name="lname" class="text"><br>
Email:<br><input type="text" name="email" class="text"><br>
Address:<br><input type="text" name="address" class="text"><br>
Apt. #:<br><input type="text" name="aptnum" class="text"><br>
City:<br><input type="text" name="city" class="text"><br>
State:<br><input type="text" name="state" class="text"><br>
Zip code:<br><input type="text" name="zip" class="text"><br>
Country:<br><input type="text" name="country" class="text"><br><br>
Means of payment:<br>
<input type="checkbox" name="check" value="check">Check<br>
<input type="checkbox" name="moneyorder" value="moneyorder">Money Order<br>
(choose only one)<br><br>
Items wanted (list full item name):<br><textarea name="question_text" rows="5" cols="50"></textarea><br><br>
<center>Before you submit please double check your information.<br>
<input type="submit" value="submit" style="font-size:8pt; font-family: verdana;"></center>
</font>
</form>
</body>
</html>
I hope that's clear. I know it looks complex, but it's relatively easy. You can, of course, also check that all the fields have been entered in a similar way, but that's probably getting too complex at this stage.