Hi,
A form mail script is very simple. There are a number of applications
that will do what you want, good places to look for these types of
things (in PHP anyway) are:
PHP Resource Index
http://php.resourceindex.com/
Hotscripts: PHP
http://www.hotscripts.com/PHP
However, as you have asked for a customised solution, here is a script
I have written for your form as it exists on that page (if you have
problems copying and pasting the following code, please check here:
http://www.upload2.net/page/download/ua8alfqJAhsYkPo/form.php.html)
Please note, I have removed email addressed to comply with Google Answers terms.
They can all be replaced exactly as they are in your current version,
also the '$email_to' address will need to be filled in.
It is fairly simple and should be easy to change later if you like.
I have changed the names of the form fields for clarity.
Let me know if you have any questions.
---CODE BEGINS---
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<head>
<meta http-equiv="Dynamics college umass acapella acappella sing
singer group university best Massachusetts coed co-ed music good great
group" content="text/html; charset=iso-8859-1"/>
<meta name="Dynamics college umass acapella acappella sing singer
group university best Massachusetts coed co-ed music good great group"
content="Dynamics college umass acapella acappella sing singer group
university best Massachusetts coed co-ed music good great group"/>
<meta name="Dynamics college umass acapella acappella sing singer
group university best Massachusetts coed co-ed music good great group"
content="Dynamics college umass acapella acappella sing singer group
university best Massachusetts coed co-ed music good great group"/>
<meta name="Dynamics college umass acapella acappella sing singer
group university best Massachusetts coed co-ed music good great group"
content="Dynamics college umass acapella acappella sing singer group
university best Massachusetts coed co-ed music good great group"/>
<link rel="stylesheet" type="text/css" href="default.css"/>
<title>Dynamics Acappella: Umass's Hottest Acappella Group</title>
</head>
<body>
<div class="main">
<div class="gfx">
<h1> </h1>
<h1> </h1>
</div>
<div class="menu">
<div align="center"><a href="index.html"><span><font
color="#FFFFFF">Home</font></span></a>
<a href="aboutus.htm"><span><font color="#FFFFFF">About Us</font></span></a>
<a href="members.htm"><span><font color="#FFFFFF">Members</font></span></a>
<a href="auditions.htm" id="last"><span><font
color="#FFFFFF">Auditions</font></span></a>
<a href="events.htm"><span><font color="#FFFFFF">Events</font></span></a>
<a href="repertiore.htm"><span><font
color="#FFFFFF">Repertiore</font></span></a>
<a href="contact.htm"><span><font color="#FFFFFF">Contact
Us</font> </span></a>
<a href="http://www.cafepress.com/umassdynamics"><span><font
color="#FFFFFF">Dynamics
Store</font></span></a> </font></div>
</div>
<div class="content">
<div class="item">
<h1><img src="img/contact.gif" width="117" height="21" /></h1>
<p><img src="img/seperate.gif" width="590" height="9" /></p>
<p><font color="#FFFFFF"><strong>Please do not hesitate to
contact us</strong>
with any questions you have about the group, our performances
and recordings,
or in regards to auditioning.</font></p>
<p><font color="#FFFFFF"><strong>General Group E-mail</strong></font></p>
<p>EMAIL ADDRESS</p>
<p><font color="#FFFFFF"><strong>General Manager</strong></font></p>
<p><font color="#FFFFFF">Andrew Rozynski - EMAIL ADDRESS</font></p>
<p><font color="#FFFFFF"><strong>Music Director</strong></font></p>
<p><font color="#FFFFFF">Emily Hall - EMAIL ADDRESS</font></p>
<p><img src="img/seperate.gif" width="590" height="9" /></p>
<p><font color="#FFFFFF"><strong>Booking information:</strong> The Dynamics
love to sing and spread the joy of singing to others. Because of this,
we offer extremely competitive, flexible rates. For your next
party, conference,
wedding, anniversary celebration or other social engagement, consider
hiring an a cappella group! We are available for singing engagements in
the Amherst/Hartford/Boston area throughout the academic year, and tour
around the nation during academic break.</font></p>
<p><img src="img/seperate.gif" width="590" height="9" /></p>
<p><font color="#FFFFFF"><img src="img/form.gif" width="137"
height="24" /></font></p>
<?php
do_form();
?>
</div>
<div class="item">
<p><img src="img/seperate.gif" width="590" height="9" /></p>
</div>
<div class="item">
<h1><font color="#FFFFFF">If you would like the Dynamics to sing at your
next Benefit, Fund Raiser, or Show please Contact
Us </span></font><font color="#000000"><span style="font-weight:
bold;">
at EMAIL ADDRESS<br>
</span> </font><BR>
</h1>
</div>
</div>
<div class="footer">Website and All contents © Dynamics Acappella 2006
</div>
</div>
</body>
</html>
<?php
function do_form() {
echo "<h1> Submit: ".$_POST["submit"]."</h1>";
if (!empty($_POST["submit"])) {
process_form();
} else {
draw_form();
}
}
function get_val($varname) {
if (!empty($_POST[$varname])) {
echo $_POST[$varname];
}
}
function get_checked($varname,$value,$default=FALSE) {
if (empty($_POST[$varname]) && $default) {
echo "checked";
} elseif (strtolower($_POST[$varname]) == strtolower($value)) {
echo "checked";
}
}
function get_selected($varname,$value,$default=FALSE) {
if (empty($_POST[$varname]) && $default) {
echo "selected";
} elseif (strtolower($_POST[$varname]) == strtolower($value)) {
echo "selected";
}
}
function draw_form() {
?>
<form method="POST" action="<? echo $_SERVER['PHP_SELF']; ?>">
<p><img src="img/howlong.gif" width="434" height="16" /></p>
<p><font color="#FFFFFF"><b>
<input type="radio" name="Event_Dur" value="Serenade" <?
get_checked("Event_Dur","Serenade"); ?>>
Serenade
<input type="radio" name="Event_Dur" value="Few_Songs" <?
get_checked("Event_Dur","Few_Songs"); ?>>
2-3 Songs
<input type="radio" name="Event_Dur" value="Full_Concert" <?
get_checked("Event_Dur","Full_Concert",TRUE); ?>>
Full Concert
<input type="radio" name="Event_Dur" value="Special_Event"
<? get_checked("Event_Dur","Special_Event"); ?>>
Special Event</b></font></p>
<p><font color="#FFFFFF" size="2"><img src="img/whattype.gif"
width="418" height="16" /></font></p>
<p><font color="#FFFFFF"><b>
<select name="Event_Type" size="1">
<option value="Company" <?
get_selected("Event_Type","Company",TRUE); ?>>Company Event</option>
<option value="High_School" <?
get_selected("Event_Type","High_School"); ?>>High School
Event</option>
<option value="Charity" <?
get_selected("Event_Type","Charity"); ?>>Charity Event</option>
<option value="College" <?
get_selected("Event_Type","College"); ?>>College Event</option>
<option value="Sporting" <?
get_selected("Event_Type","Sporting"); ?>>Sporting Event</option>
<option value="Other" <?
get_selected("Event_Type","Other"); ?>>(Other)</option>
</select>
Other:
<input type="text" size="26" maxlength="256"
name="Other_Detail" value="<? get_val("Other_Detail"); ?>">
</b></font></p> <p> </p>
<p><img src="img/please.gif" width="398" height="16" /></p>
<dl>
<dd><font color="#FFFFFF"><b><textarea name="Comments" rows="5"
cols="42"><? get_val("Comments"); ?></textarea></b></font></dd>
</dl> <p> </p>
<p><font color="#FFFFFF" size="2"><strong><img
src="img/tellus.gif" width="230" height="16" /></strong></font></p>
<dl>
<dd>
<table>
<tr>
<td><b><font color="#FFFFFF" face="Times New Roman, Times,
serif">Name</font></b></td>
<td><font color="#FFFFFF"><b>
<input type="text" size="35" maxlength="256" name="Name"
value="<? get_val("Name"); ?>"></b></font></td>
</tr>
<tr>
<td><b><font color="#FFFFFF" face="Times New Roman, Times,
serif">E-mail</font></b></td>
<td><font color="#FFFFFF"><b>
<input type="text" size="35" maxlength="256" name="Email"
value="<? get_val("Email"); ?>"></b></font></td>
</tr>
<tr>
<td><b><font color="#FFFFFF" face="Times New Roman, Times,
serif">Tel</font></b></td>
<td><font color="#FFFFFF"><b>
<input type="text" size="35" maxlength="256" name="Telephone"
value="<? get_val("Telephone"); ?>"></b></font></td>
</tr>
<tr>
<td><b><font color="#FFFFFF" face="Times New Roman,
Times, serif">Fax</font></b></td>
<td><font color="#FFFFFF"><b>
<input type="text" size="35" maxlength="256" name="Fax"
value="<? get_val("Fax"); ?>"></b></font></td>
</tr>
</table>
</dd>
</dl>
<dl>
<dd> </dd>
<dt><font color="#FFFFFF"><b>
<input type="checkbox" name="Contact_Requested"
value="Yes" <? get_checked("Contact_Requested","Yes"); ?>>
Please contact us as soon as possible for this gig.</b></font></dt>
</dl>
<p> </p>
<p><font color="#FFFFFF"><b><input type="submit" name="submit"
value="Submit">
<input type="reset" value="Clear Form"></b></font></p>
<p align="left"> </p>
</form>
<?php
}
function process_form() {
$variables = array("Name","Email","Telephone","Fax","Event_Dur","Event_Type","Other_Detail","Contact_Requested");
$required = array("Name","Email");
print_r($_POST);
$email_to = "EMAIL ADDRESS";
$email_subject = "Website Contact Form";
$email_from = $_POST["Name"] ." <". $_POST["Email"] .">";
$email_headers = "From: $email_from\r\n";
$time = date("h:i:sa d-M-y"); // See 'date' docunmentation at php.org
$error = "";
$success_message = "Thank you. Your information has been received. We
will be in contact shortly.";
// WINDOWS ONLY
// If the webserver is running Windows, uncomment the following two
lines and replace <<SMTP SERVER>> with a
// valid SMTP server address.
// ini_set("SMTP","<<SMTP SERVER>>");
// ini_set("sendmail_from",$_POST["Email"]);
$email_body = "A visitor to the website submitted a contact form at
$time with the following information: \r\n";
foreach ($variables as $var) {
if (empty($_POST[$var])) {
$value = "EMPTY";
if (in_array($var,$required)) {
$error .= "<b>$var</b> needs to be filled out.<br />\n";
}
} else {
$value = $_POST[$var];
}
$email_body .= str_replace("_"," ",$var).": $value\r\n";
}
$email_body .= "\r\n\r\nRemote IP Address: ".$_REQUEST["REMOTE_ADDR"]."\r\n";
if (empty($error)) {
$success = mail($email_to,$email_subject,$email_body,$email_headers);
if ($success) {
echo $success_message;
} else {
echo "<b>An error occured sending your form. We cannot deliver it
at present. Please contact one of us directly by email instead.</b>";
}
} else {
echo "<b>Please correct the following errors, then try again:</b><br />$error";
draw_form();
}
}
?>
---CODE ENDS---
Regards,
Sycophant |