Home arrow PHP Tutorials

Translate This Website
Saturday, 22 November 2008
Web Development
Request a Quote
Script Categories
RSS Media Grabber Funny Videos & Pictures Life Stories (Flash) Video Search & Download Video Downloader Script Country on Sale Advanced Polls Phone Upload/SMS Scripts PhotoCube Script SlideShow Creation Script Create Custom Smiley Script Short URLs & Subdomains Put your text on images Watermark & Image Hosting Joomla Components Low Cost Scripts
Partners
WEBSITE TRAFFIC
Credit Cards
Online HTML Editor
Wordpress Themes
Custom Programming
Scripts and Stuffs
Hot php scripts
Add your scripts
Script Search
php scripts directory
script heaven
the cgi site
Scripts
Software Development
Free Icons
SEO Services


A Beginning Forms Tutorial Print E-mail
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";
?>


This function generates the form itself



<?
function show_form($first="", $last="", $email="") {
?>
<FORM ACTION="form2.php3" METHOD="Post">
First Name:<INPUT TYPE=text NAME=first VALUE="<?echo $first?>">
Last Name:<INPUT TYPE=text NAME=last VALUE="<?echo $last?>">
Email:<INPUT TYPE=text NAME=email VALUE="<?echo $email?>">
<INPUT TYPE="submit" VALUE="Send Form">
</FORM>
<? }


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!).

Credit: phpdeveloper.org




Reddit!Del.icio.us!Facebook!Slashdot!Netscape!Technorati!StumbleUpon!Newsvine!Furl!Yahoo!Ma.gnolia!Free social bookmarking plugins and extensions for Joomla! websites!
 
< Prev   Next >
Services
Script Installation
Hosting
Free Image Hosting
PageRank Checker
Login Form
On Sale
Funny Videos and Pictures Script
Funny Videos and Pictures Script
$69.00
$59.00
You Save: $10.00
Add to Cart
Home Announcements Support Newsletter Forum PHP Articles PHP Tutorials Scripts FAQs Free Scripts Links Contacts
Copyrighted © 2008 phppod.com