I'm pretty new to this myself, and this is what I've come up with for our site that seems to work fine. I've included my simple php contactscript, followed by the portion of our site's XHTML that creates the form and ties it to the script. We only have fields for name, e-mail address, and a text box, but it would be trivial to add more fields in the XHTML code and the php code.
I've commented the php pretty heavily even though it is very simple, in the hope that it will make it clear what's going on at each step. Hope it helps!
Craig
Sunnyvale, California
================ contactscript.php ===================
<?php
/ Comment: This php script generates an automatic message /
/ and sends it to the webmaster's e-mail address at the Friends /
/ of the Sunnyvale Library web domain (fotsvl.org) after stripping /
/ out HTML code from the entry fields. /
$name = $POST['name'];
$email = $POST['email'];
$comments = $_POST['comments'];
/ The 3 lines above pull in the 3 form fields from the web page /
$strippedname = strip_tags($name);
$strippedemail = strip_tags($email);
$strippedcomments = strip_tags($comments);
/ The 3 lines above remove HTML tags from the form fields /
$to = "webmaster@fotsvl.org";
$subject = "Submission from web site 'Contact Us' page";
$message = "This message was sent automatically from the Friends of the Library \n" .
"web site's 'Contact Us' page. The sender provided the following info: \n" .
"\n" .
"Name: $strippedname\n" .
"E-mail address: $strippedemail\n" .
"\n" .
"Comments: $strippedcomments\n" .
"\n";
header( "Location: http://fotsvl.org/contactformsubmitted.html" );
/ The above 'header' line causes a special web page to load after the /
/ user presses the submit button. The special page has the same basic /
/ layout, font, and nav buttons as our site's regular pages, but its only
/ content is a blurb that says 'Thank you, your message has been sent.' */
mail($to,$subject,$message);
/ The above line is the code that actually sends the message. /
?>
================ XHTML snippet =====================
<div id="form">
<form class="indent" action="contactscript.php" method="post">
<br />
<br />
<table align="center">
<tr>
<td class="formlabeltext">Name: </td>
<td> <input type=text name="name" size=30 /></td>
</tr>
<tr>
<td class="formlabeltext">Email:</td>
<td> <input type=text name="email" size=30 /></td>
</tr>
</table>
<br />
<p class="center">
<!-- Note: the 'center' class is something I defined in my CSS file -->
<textarea name="comments" cols=35 rows=5></textarea>
<br />
<br />
<input type=submit value="Send Message" /></p>
</form>
</div>