Ever wondered how you can use a form to log someone in, or get information from the user and drop it into a database? Well, fear no more! We have a good example of how to get all of the info from those elusive cells. This example also shows you how to make sure that they don't leave a field blank. First, we'll start with the code for the page and explain it as we go along:
<HTML> <HEAD <TITLE>E-Mail Form Code</TITLE> <BODY> form test <? This section sets the defaults for the scripts $msg = "First Name:$first"; $msg .= "Last Name:$last"; $msg .= "E-mail Address:$email"; $recipient = "
"; $subject = "Feedback from A&E Form"; $mailheaders = "From: A&E Web Site <
>"; $mailheaders .= "Reply-To: $email"; ?>
Here's the end of that function and the beginning of the next section. This section does the job of parsing the input that the form got and taking it and mailing it to the email address specified above.
if(!isset($first)) { show_form(); }elseif(!$email == "" && (!strstr($email,"@") || !strstr($email,"."))) echo "Please enter a valid e-mail address<P>n"; show_form($first,$last); }else { if(empty($first) || empty($last) || empty($email)) { echo "You did not fill in all the fields, please try again<P>n"; show_form($first,$last,$email); }else { echo "Thank you, $first $last, you have sent the e-mail form"; mail($recipient, $subject, $msg, $mailheaders); } } ?>
Any there you have it. A simple email form that you can use for feedback on your site (assuming the server it's on is running sendmail or something similar!).