PHPJavascript

Web Development Guide – My Personal Library of Tutorials and Scripts

(Contactus script) Build PHP Database Driven Websites – Tutorial 3a

September13

Download

Previously we had build the database structure, CMS and website interface for an online egames website and now we will develop a contactus script for the same.
Recap:

  • We are building a simple ecommerce dynamic website called games
  • So far we have build a database structure, CMS and website interface .
  • Download file 75.rar. “start” folder consist of the work done previously and “final” folder consist of the complete work done in this tutorial

Note: I would like to point out that this contact script will work only on your website server and not on your local computer. So upload the script before you test!!!! Contactus Script Consists of two pages contact.php (HTML Form) and send.php (script)

contact.php

Type <SCRIPT language="JavaScript" src="gen_validatorv1.js" type="text/javascript"></SCRIPT> in the <head></head>

Find <!— listing —> and type the following:

Explanation

Code Explanation
<SCRIPT language="JavaScript" src="gen_validatorv1.js" type="text/javascript"></SCRIPT> Javascript for validation purpose only
<input type="text" name="username" width="350"/>
<input type="text" name="email" />
<textarea cols="40" rows="7" name="comments" /></textarea>
HTML form elements to be passed on to send.php

send.php

Find <!— listing —> and type the following:

Explanation

Code Explanation
$name=$_POST["username"];
$email=$_POST["email"];
$comments=$_POST["comments"];
Extracting values from the previous form
$to= "info@phpjavascript.com";
$headers ="From: $email\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=iso-8859-1 \n";
$subject ="User Comments";
setting up variables for mail() function
mail($to,$subject,$body,$headers) PHP mail() function
posted under Development Guide

Email will not be published

Website example

Your Comment:

 

3,048 spam comments
blocked by
Akismet