Version: 1.0
Type: Full Script
Category: HTML
License: GNU General Public License
Description: A simple script allowing a form to be filled and emailed to the corresponding e-mail. It has only a very simple check for certain feilds to be entered but it quite useful.
<HTML>
<HEAD>
<TITLE>html-form</TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</HEAD>
<?
/*
*************
This very simple enquiry form was written by Sean Gibson
And is not guaranteed in any way or form.
This program is free software; you can redistribute it
and/or modify it under the terms of the GNU GPL.
This program is distributed in the hope that it will be
useful, but without any warranty; without even the implied
warranty of merchantability or fitness for a particular
purpose. See the GNU General Public License for more
details.
You should not have received a copy of the license referred
to here as you probably already have one.
----------------Cut and paste the html code and save as form.html---------------
<html>
<head>
<title>Enquiry form</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF">
<form action="/confirm.php" method="POST" >
<div align="center">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="71">
<div align="center"><font size="6" color="#EABB00"><b><font color="#333399">
<font color="#EABB00">Customer Enquiry Form:</font></font></b></font>
</div>
</td>
</tr>
</table>
<hr width="95%" size="3">
<div align="center">
<input type="hidden" name="recipient">
<input type="hidden"
name="subject" value="Web Enquiry">
<input type="hidden" name="redirect"
value="a web address of your choice">
</div>
</div>
<div align="center">
<table width="51%" border="0" cellspacing="5" cellpadding="5" class="FormCSS" align="center" height="608">
<tr>
<td width="33%">
<div align="left"><font color="#EABB00"><b><font size="3" face="Times New Roman, Times, serif">Name:</font></b></font></div>
</td>
<td width="67%">
<input type="text" size="50"
maxlength="50" name="realname">
</td>
</tr>
<tr>
<td width="33%">
<div align="left"><font color="#EABB00"><b><font size="3" face="Times New Roman, Times, serif">Organization:</font></b></font></div>
</td>
<td width="67%">
<input type="text" size="50" maxlength="50"
name="organisation">
</td>
</tr>
<tr>
<td width="33%">
<div align="left"><font color="#EABB00" size="3" face="Times New Roman, Times, serif"><b>Address:</b></font>
</div>
</td>
<td width="67%">
<textarea cols="50" name="address_line_1" rows="5"></textarea>
</td>
</tr>
<tr>
<td width="33%">
<div align="left"><font color="#EABB00">PostCode:</font></div>
</td>
<td width="67%">
<input type="text" size="10" maxlength="15" name="postcode">
</td>
</tr>
<tr>
<td width="33%">
<div align="left"><font color="#EABB00">Telephone: (incl std:)</font></div>
</td>
<td width="67%">
<input type="text" size="50"
maxlength="50" name="telephone">
</td>
</tr>
<tr>
<td width="33%">
<div align="left"><font color="#EABB00">Fax:</font></div>
</td>
<td width="67%">
<input type="text" size="50" maxlength="50"
name="fax">
</td>
</tr>
<tr>
<td width="33%">
<div align="left"><font color="#EABB00">Email:</font></div>
</td>
<td width="67%">
<input type="text" size="50" maxlength="50" name="email">
</td>
</tr>
<tr>
<td width="33%"><font color="#EABB00">Type of enquiry:<br>
(e.g. repairs, faultfinding etc.)</font></td>
<td width="67%">
<textarea
name="text" rows="5" cols="50"></textarea>
</td>
</tr>
<tr>
<td colspan="2" height="2">
<div align="center"> <font color="#EABB00">
<input type="submit" name="send form" value="Submit Enquiry">
<input
type="reset" name="clear form" value="Reset Form">
</font></div>
</td>
</tr>
</table>
</div>
<div align="center">
<div align="right">
<div align="left">
<pre class="FormCSS"> </pre>
<c></c></div>
</div>
</div>
</form>
<div align="center"><c><a href="index.html"><font face="Times New Roman, Times, serif" size="3" color="#333399"><b><font color="#EABB00">If
you do not wish to complete the form Click here to return to the Index Page</font></b></font></a></c>
</div>
</body>
</html>
----------------------------to here------------------------------------
save the php as confirm.php in your web site
*/
<BODY BGCOLOR="#FFFFFF">
<%
if ((!$realname ) or (!$telephone) && (!$email)) {
echo "Please Enter a Contact Name and either a Telephone Number or an
Email address for Contact purpose's.
Thank You";
echo "<p>";
echo "Please use the 'Back' button to continue.";
echo "</p>";
echo "<a href='/form.html' onclick='self.history.back();'>Back</a>";
exit;
}
$message="Name: $realname\n\n"."Organisation: $organisation\n\n"."Address:\n$address_line_1\n\n"."Post Code: $postcode\n\n"."Telephone: $telephone\n\n"."Fax: $fax\n\n"."Email: $email\n\n".
"Message: \n".$text;
mail("your e-mail address","$subject","$message","From:Form.$email\r\nReply-to:$email");
echo "<p>Thank you for completing our contact form. Your details have been forwarded and we will be in contact within 2 working days.</p>";
echo "<p>From: $email</P>";
echo "<p>Subject: $subject</p>";
echo "<p>Message: </p>";
echo "<p>";
echo $text;
echo "</p><a href='/index.html'><b>Return to the Index Page</b></a>";
%>
</BODY>
</HTML>