View Single Post
Old 10-23-2008, 07:34 PM   #2 (permalink)
fnacotton
Junior Member
 
fnacotton's Avatar
 
Join Date: Sep 2008
Location: USA
Posts: 59
Default Re: clientside or serverside for e mail form

It is my opinion that server side form handling is the easiest and safest to implement. Some users like to browse without javascript turned on for some reason. This is a pretty simple form, no validation, but it asks for a name, email, and a short message. The action is set to the path of a mail.php file. In the mail.php file you'll see that it gets the values of the form based on the names assigned to the inputs, then emails them to you, and returns the user to some page.

Code:
your form
<form action="mail.php" method="post">
<label for="name">name:</label> <input type="text" id="name" name="name"><br>
<label for="email">email:</label> <input type="text" id="email" name="email"><br>
<label for="message">message:</label> <textarea name="message" id="message"></textarea><br>
<input type="submit" value="send">
</form>
Code:
for a script called mail.php
<?php
$name = $_REQUEST['name'];
$email = $_REQUEST['email'];
$message = $_REQUEST['message'];
$body = "
$name
$email
$message";
mail("youremail@address.com", "Email subject", $body, "From: $email"); header("Location: http://www.whereyouwanttheirbrowsertogo.com/thanks.html");
?>
__________________
FNA Cotton, fna
CSS help | cool t-shirts | portfolio

Last edited by fnacotton; 10-23-2008 at 07:36 PM..
fnacotton is offline   Reply With Quote
Sponsored Links