spacer 
main navigation left corner main navigation right edge
Search Engine Optimization Service Thailand
left corner rounded edge content background spacer right corner rounded content background
navigation arrow Home navigation arrow Hosting navigation arrow  How to create a mailform
 

Mail Form Example with PHP Function

 
spacer About Seo Watch SEO Hosting Services spacer


spacer
How to create a mailform

Making a mail form

  • You need to create 4 files.
  • http://www.yourdomain.com/mailform.php
  • http://www.yourdomain.com/error_page.php
  • http://www.yourdomain.com/thank_you_page.php
  • http://www.yourdomain.com/mail_function.php

The form will look like this

Name:
Email:spacer
Message



Copy and paste then save it as mail_function.php upload it to the same folder where you place the mailform.php

// ------------- THIS YOU CAN EDIT ------------------------

// $mailto - Fill in your E-mail address
// sent to
//$mailto = "E-mail@yourdomain.com" ;

// --- FILL IN THE CC E-MAIL ADDRESS-------
$mailto = 'E-mail@yourdomain.com' ;

// $subject - Fill in the subject line of the email
//$subject = "Mail Message " ;

$subject = "mail message " ;

// the pages that are displayed
//$mailformurl = "http://www.yourdomain.com/mailform.php" ;
//$error_pageurl = "http://www.yourdomain.com/error_page.php" ;
//$thank_you_pageurl = "http://www.yourdomain.com/thank_you_page.php" ;

$mailformurl = "http://www.yourdomain.com/mailform.php" ;
$error_pageurl = "http://www.yourdomain.com/error_page.php" ;
$thank_you_pageurl = "http://www.yourdomain.com/thank_you_page.php" ;

$uself = 0;

// -------------------- MAIL FORM FUNCTION ---------------

$headersep = (!isset( $uself ) || ($uself == 0)) ? "\r\n" : "\n" ;
$name = $_POST['name'] ;
$email = $_POST['email'] ;
$message = $_POST['message'] ;
$http_referrer = getenv( "HTTP_REFERER" );

if (!isset($_POST['email'])) {
header( "Location: $mailformurl" );
exit ;
}
if (empty($name) || empty($email) || empty($message)) {
header( "Location: $error_pageurl" );
exit ;
}
if ( ereg( "[\r\n]", $name ) || ereg( "[\r\n]", $email ) ) {
header( "Location: $error_pageurl" );
exit ;
}

if (get_magic_quotes_gpc()) {
$message = stripslashes( $message );
}

$messageproper =

"This message was sent from:\n" .
"$http_referrer\n" .
"------------------------------------------------------------\n" .
"Name of sender: $name\n" .
"Email of sender: $email\n" .
"------------------------- MESSAGE -------------------------\n\n" .
$message .
"\n\n------------------------------------------------------------\n" ;

mail($mailto, $subject, $messageproper,
"From: \"$name\" <$email>" . $headersep . "Reply-To: \"$name\" <$email>" . $headersep . "mailform.php" );
header( "Location: $thank_you_pageurl" );
exit ;

?>

Copy and paste it to your mailform.php file

<form action="mail_function.php" method="post">
Name: <input type="text" name="name" size="25" /><br />
Email: <input type="text" name="email" size="25" /><br />
Message<br />
<textarea rows="15" cols="45" name="message"></textarea><br />

<input type="submit" value="Send" /><br />
</form>







For more information on arrow Google Adwords or arrow Search Engine optimization for your company or web site, please contact us by arrow inquiry form or arrow e-mail us
spacerspacer header top cubes Web Hosting spacer
SEO WATCH is known for successful seo marketing, and offers 24/7 support to our web hosting clients. If you have any questions about our seo or hosting packages please call us: +66 (0)35 231214
... arrow Web Hosting Services
header top cubes Search Engine Friendly Hosting
Choosing a hosting company for your site is a big decision. When you make a decision to host your web site with a web host provider, you're actually placing your search engine rankings and income in the hands of your hosting provider. The wrong web hosting plan or service provider can cause big damages to your search engine ranking and you not aware of it.
... arrow SEO Friendly Hosting
header top cubes Online Shop Optimization
Search engine optimization for E-commerce sites that are based on content management systems, os Commerce, phpShop, Zen Cart, ASP, this means: URLs and pages are dynamically generated by the scripting language fetching all elements from the database.
... arrow E-Commerce Optimization
header top cubes Search Engine News
Your web site should be informative and search engine friendly. If you are the owner of a web site, make sure that there are no technical errors that prevent search engines from indexing your web pages and only hire a professional search engine optimization company to improve ranking in search results, if you cannot manage yourself.
... arrow  Search Engine News
header top cubes SEO Optimization Packages
We offer many different kind of flexible seo packages to keep our customers satisfied, to be affordable for all marketing department budgets and achieve the best results for their web site.
... arrow  SEO Optimization Packages
header top cubesSuccessful SEO Projects
View our clients and companies who used our seo consulting services.
... arrow Successful SEO Projects
spacer spacer


Effective Seo  Marketing


Give Feedback