Email Contact form

A contact form that uses php to send captured info to any specified email. Error reporting, Required fields and Multiple email support. You can use this form to allow your users to contact you via your web page. A very simple script that can be used on any site that has php installed.

First, download the example code

(3.65kb) 2mellow-contact-form.zip click here to download.

 

How to Install

installing this script to your web page will consist of mostly installing the files properly to your server, editing a few variables, and putting the form into your page.

Step 1

Now that you have downloaded the zip you will notice 2 folders. Upload these folders to the root folder of your site (http://www.yoursite.com/functions/) and (http://www.yoursite.com/scripts/).

Step 2

Now you need to add this code to the top of the page where the contact form will be.

Example:

1
2
3
4
	<?PHP
		session_start();
		include("/includes/functions.php");
	?>

Step 3

Now we will edit /scripts/process.php. Find this code and edit accordingly:

1
2
3
4
5
6
/*****************************************/
//GENERAL CONFIGURATION
$developer = "webmaster@eyoursite.com";
$to = "youremail@yoursite.com";
$from = "thesender@yoursite.com";
/*****************************************/

Step 4

Now in the same file you’ll want to edit the redirect location. Any where you see this line edit it to be the page your contact form is located on:

1
header("Location: /index.php");

Step 5

Now paste the form where you want the user to see it! Here is the code located in index.php in the zip file:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<h1>Contact form</h1>
<?PHP
	$title = "contact";
 
	//GET FORMATTED ERROR MESSAGE IF ONE EXISTS
	getFormattedMessage();
 
	//EMPTY THE RESETTED MESSAGE
	clearMessages(); 
?>
 
<p>Please fill out the form below to contact Your Site.</p>
<form action="/scripts/process.php" method="post">
	<table cellpadding="2" cellspacing="0" border="0">
		<tr>
			<td>* Your Name:&nbsp;&nbsp; </td>
			<td><input type="text" name="name" class="input" size="40"<?PHP if($_SESSION[$title]['name']) { echo(" value=\"{$_SESSION[$title]['name']}\""); } ?>></td>
		</tr>
				<tr>
			<td>&nbsp;&nbsp;Your Phone:&nbsp;&nbsp; </td>
			<td><input type="text" name="phone" class="input" size="40"<?PHP if($_SESSION[$title]['phone']) { echo(" value=\"{$_SESSION[$title]['phone']}\""); } ?>></td>
		</tr>
				<tr>
			<td>* Your Email:&nbsp;&nbsp; </td>
			<td><input type="text" name="email" class="input" size="40"<?PHP if($_SESSION[$title]['email']) { echo(" value=\"{$_SESSION[$title]['email']}\""); } ?>></td>
		</tr>
		<tr>
			<td valign="top">* Message:&nbsp;&nbsp;</td>
			<td><textarea name="message" cols="40" rows="6" class="input"><?PHP if($_SESSION[$title]['message']) { echo($_SESSION[$title]['message']); } ?></textarea></td>
		</tr>
		<Tr>
			<td>&nbsp;</td>
			<td>
				<input type="hidden" name="action" value="contact" />
				<input type="submit" value="Send Contact Form" class="submit">
			</td>
		</Tr>
	</table>
</form>

Thank you for your interest in 2mellow.com. If this script was helpful please recommend us by clicking the social links below.

 
 
Leave A Reply Here

  Username [*]

  Email Address [*]

  Website

Subscribes to this post comments updates

Please Note: All comments maybe under going moderation so there is no need to resubmit the comments. it will appeared when admin approved it, feel free to subscribes to the post comments rss to stay update