Hello everyone,
This is my first post to this forum (and my first attempt at PHP), so I am hoping someone can assist me with a problem I cannot get my head around.
I am a retired old git with no real IT training, but I have created a website for our small village, which includes an online form for people to contact us.
Currently the form works fine(ish) and sends the relevant details filled out on the form to me.
Within the form is a “Please select” list box with various village functions. i.e. Village Hall, Parish Council, Marquee Hire & etc. I am trying to get it to send the form information to different people in the village, depending on which village function is selected. This is where I am coming unstuck, and I simply do not understand what or why, so I hope someone can show me the error of my ways (other than don’t mess with what you don’t understand ?)
My php code is:
[code=php]
<?php
/* Email Variables */
$emailSubject = ‘website_enquiry’;
$recipients = array(
‘recipient_1’ => ‘[email protected]’,
‘recipient_2’ => ‘[email protected]’,
‘recipient_3’ => ‘[email protected]’,
‘recipient_4’ => ‘[email protected]’,
‘recipient_5’ => ‘[email protected]’,
‘recipient_6’ => ‘[email protected]’,
‘recipient_7’ => ‘[email protected]’
);
$my_email = $recipients[$_REQUEST[‘Nature’]];
/* Data Variables */
$Name = $_POST[‘Name’];
$Telephone = $_POST[‘Telephone’];
$Email = $_POST[‘Email’];
$Nature = $_POST[‘Nature’];
$Questions = $_POST[‘Questions’];
$body = <<<EOD
<br><hr><br>
Name: $Name <br>
Telephone: $Telephone <br>
Email: $Email <br>
recipient: $recipient <br>
Questions: $Questions <br>
EOD;
$headers = “From: $Emailrn”;
$headers .= “Content-type: text/htmlrn”;
$success = mail($my_email, $emailSubject, $body,
$headers);
/* Results */
$theResults = <<<EOD
<html>
<head>
<title>sent message</title>
<meta http-equiv=”refresh” content=”3;URL=http://example.com/index.html”>
<style type=”text/css”>
<!–
body {
background-color: #444;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 20px;
font-style: normal;
line-height: normal;
font-weight: normal;
color: #fec001;
text-decoration: none;
padding-top: 200px;
margin-left: 150px;
width: 800px;
}
–>
</style>
</head>
<div align=”center”>Thank you for your enquiry. Your message has been sent and we will respond as soon as possible</div>
</div>
</body>
</html>
EOD;
echo “$theResults”;
?>
and the relevant part of the html within the contact form is:
[code=html]
<td width=”50%” height=”56″><div align=”center”>Nature of your Enquiry ?</div></td>
<td width=”50%”><div align=”center”>
<select name=”Nature” size=”1″ id=”Nature”>
<option>Please Select</option>
<option value=”recipient_1″>General Enquiries</option>
<option value=”recipient_2″>Hall Hire</option>
<option value=”recipient_3″>Marquee Hire</option>
<option value=”recipient_4″>Parish Church</option>
<option value=”recipient_5″>Parish Council</option>
<option value=”recipient_6″>Recreation Area</option>
<option value=”recipient_7″>Other</option>
</select>
</div></td>
I am pretty sure I have done something simple but stupid, so any guidance to help sort this out would be much appreciated.
[code=php]
error_reporting(E_ALL | E_NOTICE);
ini_set('display_errors', '1');
[/code]
[code=php] $emailto = '[email protected]';[/code]
[code=php]
$recipients = array(
'recipient_1' => '[email protected]',
'recipient_2' => '[email protected]',
'recipient_3' => '[email protected]',
'recipient_4' => '[email protected]',
'recipient_5' => '[email protected]',
'recipient_6' => '[email protected]',
'recipient_7' => '[email protected]'
);
$my_email = $recipients[$_REQUEST['Nature']];
[/code]
[code=php] <meta http-equiv="refresh" content="3;URL=http://example.com/index.html"> [/code]
which is the fourth row within "the results" section of my code above.[code=html]
<html>
<head>
<title>Welcome to Example - Contact Us</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_validateForm() { //v4.0
var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
if (val) { nm=val.name; if ((val=val.value)!="") {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.n';
} else if (test!='R') { num = parseFloat(val);
if (isNaN(val)) errors+='- '+nm+' must contain a number.n';
if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.n';
} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.n'; }
} if (errors) alert('The following error(s) occurred:n'+errors);
document.MM_returnValue = (errors == '');
}
//-->
</script>
</head>
<body bgcolor="#FFFFFF" background="goldmold.jpg">
<div id="Layer1" style="position:absolute; width:207px; height:42px; z-index:3; left: 10px; top: 19px;"><font size="6" face="Calligraph421 BT"><strong>Welcome
to <font size="7">example</font></strong></font></div>
<h1> </h1>
<p align="center"><font size="+4"><strong>Contact Us</strong></font></p>
<hr>
<div align="right"><font size="-1"><strong><a href="index.html" style="text-decoration = None"><font color="#000000" face="Calligraph421 BT">Return
to Home Page</font></a></strong></font></div>
<blockquote>
<blockquote>
<blockquote>
<p align="center"><font size="+1" face="Calligraph421 BT"><strong>For any
enquiries relating to the Village Hall, please either telephone the Bookings
Secretary between 08:00 and 20:00 Monday to Friday on 0845-643-0000, or
<a href="mailto:[email protected]"><font color="#0000FF">Email</font></a>
her with any questions.</strong></font></p>
</blockquote>
</blockquote>
</blockquote>
<p align="center"><strong><font size="+1" face="Calligraph421 BT">Alternatively,
or for other village matters, please complete and submit the short form below,
and we will respond as soon as possible</font></strong></p>
<form action="website_enquiry.php" method="post" enctype="multipart/form-data" name="Contact" id="Contact">
<table width="50%" border="1" align="center">
<tr>
<td width="50%" height="64"><div align="center">Full Name:</div></td>
<td width="50%"><div align="center">
<input name="Name" type="text" id="Name" size="48%">
</div></td>
</tr>
<tr>
<td width="50%" height="64"><div align="center">Telephone No.</div></td>
<td width="50%"><div align="center">
<input name="Telephone" type="text" id="Telephone" size="48%">
</div></td>
</tr>
<tr>
<td width="50%" height="67"><div align="center">Email:</div></td>
<td width="50%"><div align="center">
<input name="Email" type="text" id="Email" size="48%">
</div></td>
</tr>
<tr>
<td width="50%" height="56"><div align="center">Nature of your Enquiry ?</div></td>
<td width="50%"><div align="center">
<select name="Nature" size="1" id="Nature">
<option selected>Please Select</option>
<option>Hall Hire</option>
<option>Marquee Hire</option>
<option>Recreation Area</option>
<option>Social Club</option>
<option>Parish Church</option>
<option>Other</option>
</select>
</div></td>
</tr>
<tr>
<td width="50%" height="127"><div align="center">Enquiry Details:</div></td>
<td width="50%"><div align="center">
<textarea name="Questions" cols="40%" rows="4" id="Questions"></textarea>
</div></td>
</tr>
<tr>
<td width="50%"><div align="center">
<input name="contactSubmit" type="submit" id="contactSubmit" onClick="MM_validateForm('Name','','R','Telephone','','RisNum','Email','','NisEmail','Questions','','R');return document.MM_returnValue" value="Submit">
</div></td>
<td width="50%"><div align="center">
<input name="ContactReset" type="reset" id="ContactReset" value="Reset">
</div></td>
</tr>
</table>
<p> </p>
<p> </p>
</form>
<p align="center"> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
</body>
</html>
[/code]
[code=php]
<?php
/* Contact Enquiry Form PHP */
/* Email Variables */
$emailSubject = 'website_enquiry';
$emailto = '[email protected]';
/* Data Variables */
$Name = $_POST['Name'];
$Telephone = $_POST['Telephone'];
$Email = $_POST['Email'];
$Nature = $_POST['Nature'];
$Questions = $_POST['Questions'];
$body = <<<EOD
<br><hr><br>
Name: $Name <br>
Telephone: $Telephone <br>
Email: $Email <br>
Nature: $Nature <br>
Questions: $Questions <br>
EOD;
$headers = "From: $Emailrn";
$headers .= "Content-type: text/htmlrn";
$success = mail($emailto, $emailSubject, $body,
$headers);
/* Results*/
$theResults = <<<EOD
<html>
<head>
<title>sent message</title>
<meta http-equiv="refresh" content="3;URL=http://Donyatt.com/index.html">
<style type="text/css">
<!--
body {
background-color: #444;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 20px;
font-style: normal;
line-height: normal;
font-weight: normal;
color: #fec001;
text-decoration: none;
padding-top: 200px;
margin-left: 150px;
width: 800px;
}
-->
</style>
</head>
<div align="center">Thank you for your enquiry. Your message has been sent and we will respond as soon as possible</div>
</div>
</body>
</html>
EOD;
echo "$theResults";
?>
[/code]
[code=html]
<html>
<head>
<title>Welcome to Example - Contact Us</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_validateForm() { //v4.0
var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
if (val) { nm=val.name; if ((val=val.value)!="") {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.n';
} else if (test!='R') { num = parseFloat(val);
if (isNaN(val)) errors+='- '+nm+' must contain a number.n';
if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.n';
} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.n'; }
} if (errors) alert('The following error(s) occurred:n'+errors);
document.MM_returnValue = (errors == '');
}
//-->
</script>
</head>
<body bgcolor="#FFFFFF" background="goldmold.jpg">
<div id="Layer1" style="position:absolute; width:207px; height:42px; z-index:3; left: 10px; top: 19px;"><font size="6" face="Calligraph421 BT"><strong>Welcome
to <font size="7">Example</font></strong></font></div>
<h1> </h1>
<p align="center"><font size="+4"><strong>Contact Us</strong></font></p>
<hr>
<div align="right"><font size="-1"><strong><a href="index.html" style="text-decoration = None"><font color="#000000" face="Calligraph421 BT">Return
to Home Page</font></a></strong></font></div>
<blockquote>
<blockquote>
<blockquote>
<p align="center"><font size="+1" face="Calligraph421 BT"><strong>For any
enquiries relating to the Village Hall, please either telephone the Bookings
Secretary between 08:00 and 20:00 Monday to Friday on 0845-643-0000, or
<a href="mailto:[email protected]"><img src="emailbutton.jpg" width="70" height="20" border="0"></a>
her with any questions.</strong></font></p>
</blockquote>
</blockquote>
</blockquote>
<p align="center"><strong><font size="+1" face="Calligraph421 BT">Alternatively,
or for other village matters, please complete and submit the short form below,
and we will respond as soon as possible</font></strong></p>
<form action="website_enquiry_process.php" method="post" enctype="multipart/form-data" name="Contactform" id="Contactform">
<table width="50%" border="1" align="center">
<tr>
<td width="50%" height="64"><div align="center">Full Name:</div></td>
<td width="50%"><div align="center">
<input name="Name" type="text" id="Name" size="48%">
</div></td>
</tr>
<tr>
<td width="50%" height="64"><div align="center">Telephone No.</div></td>
<td width="50%"><div align="center">
<input name="Telephone" type="text" id="Telephone" size="48%">
</div></td>
</tr>
<tr>
<td width="50%" height="67"><div align="center">Email:</div></td>
<td width="50%"><div align="center">
<input name="Email" type="text" id="Email" size="48%">
</div></td>
</tr>
<tr>
<td width="50%" height="56"><div align="center">Nature of your Enquiry ?</div></td>
<td width="50%"><div align="center">
<select name="Nature" size="1" id="Nature">
<option>Please Select</option>
<option value="recipient_1">General Enquiries</option>
<option value="recipient_2">Hall Hire</option>
<option value="recipient_3">Marquee Hire</option>
<option value="recipient_4">Parish Church</option>
<option value="recipient_5">Parish Council</option>
<option value="recipient_6">Recreation Area</option>
<option value="recipient_7">Other</option>
</select>
</div></td>
</tr>
<tr>
<td width="50%" height="127"><div align="center">Enquiry Details:</div></td>
<td width="50%"><div align="center">
<textarea name="Questions" cols="40%" rows="4" id="Questions"></textarea>
</div></td>
</tr>
<tr>
<td width="50%"><div align="center">
<input name="contactSubmit" type="submit" id="contactSubmit" onClick="MM_validateForm('Name','','R','Telephone','','RisNum','Email','','NisEmail','Questions','','R');return document.MM_returnValue" value="Submit">
</div></td>
<td width="50%"><div align="center">
<input name="ContactReset" type="reset" id="ContactReset" value="Reset">
</div></td>
</tr>
</table>
<p> </p>
<p> </p>
</form>
<p align="center"> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
</body>
</html>
[/code]
[code=php] $my_email = $recipients[$_REQUEST['Nature']];[/code]
<i>
</i>echo "my email is $my_email<br>";
echo "subject is $emailSubject<br>";
echo "body is $body<br>";
echo "headers are $headers<br>";
<i>
</i>error_reporting(E_ALL | E_NOTICE); // Kinds of errors to show
ini_set('display_errors', '1'); // turn on display at the client to display the messages
font-style: normal;
line-height: normal;
font-weight: normal;
[code=html]<html>
<head>
<title>sent message</title>
<meta http-equiv="refresh" content="3;URL=http://example.com/index.html">
<style type="text/css">
body {
background-color: #444;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 20px;
color: #fec001;
padding-top: 200px;
width: 800px;
margin: auto;
text-align: center;
}
</style>
</head>
<body>
<div>Thank you for your enquiry. Your message has been sent and we will respond as soon as possible.</div>
</body>
</html>[/code]
[code=html]
<html>
<head>
<title>Welcome to Example - Contact Us</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_validateForm() { //v4.0
var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
if (val) { nm=val.name; if ((val=val.value)!="") {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.n';
} else if (test!='R') { num = parseFloat(val);
if (isNaN(val)) errors+='- '+nm+' must contain a number.n';
if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.n';
} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.n'; }
} if (errors) alert('The following error(s) occurred:n'+errors);
document.MM_returnValue = (errors == '');
}
//-->
</script>
</head>
<body bgcolor="#FFFFFF" background="goldmold.jpg">
<div id="Layer1" style="position:absolute; width:207px; height:42px; z-index:3; left: 10px; top: 19px;"><font size="6" face="Calligraph421 BT"><strong>Welcome
to <font size="7">Example</font></strong></font></div>
<h1> </h1>
<p align="center"><font size="+4"><strong>Contact Us</strong></font></p>
<hr>
<div align="right"><font size="-1"><strong><a href="index.html" style="text-decoration = None"><font color="#000000" face="Calligraph421 BT">Return
to Home Page</font></a></strong></font></div>
<blockquote>
<blockquote>
<blockquote>
<p align="center"><font size="+1" face="Calligraph421 BT"><strong>For any
enquiries relating to the Village Hall, please either telephone the Bookings
Secretary between 08:00 and 20:00 Monday to Friday on 0845-643-0000, or
<a href="mailto:[email protected]"><img src="emailbutton.jpg" width="70" height="20" border="0"></a>
her with any questions.</strong></font></p>
</blockquote>
</blockquote>
</blockquote>
<p align="center"><strong><font size="+1" face="Calligraph421 BT">Alternatively,
or for other village matters, please complete and submit the short form below,
and we will respond as soon as possible</font></strong></p>
<form action="website_process.php" method="post" enctype="multipart/form-data" name="Contactform" id="Contactform">
<table width="50%" border="1" align="center">
<tr>
<td width="50%" height="64"><div align="center">Full Name:</div></td>
<td width="50%"><div align="center">
<input name="Name" type="text" id="Name" size="48%">
</div></td>
</tr>
<tr>
<td width="50%" height="64"><div align="center">Telephone No.</div></td>
<td width="50%"><div align="center">
<input name="Telephone" type="text" id="Telephone" size="48%">
</div></td>
</tr>
<tr>
<td width="50%" height="67"><div align="center">Email:</div></td>
<td width="50%"><div align="center">
<input name="Email" type="text" id="Email" size="48%">
</div></td>
</tr>
<tr>
<td width="50%" height="56"><div align="center">Nature of your Enquiry ?</div></td>
<td width="50%"><div align="center">
<select name="Nature" size="1" id="Nature">
<option>Please Select</option>
<option value="recipient_1">General Enquiries</option>
<option value="recipient_2">Hall Hire</option>
<option value="recipient_3">Marquee Hire</option>
<option value="recipient_4">Parish Church</option>
<option value="recipient_5">Parish Council</option>
<option value="recipient_6">Recreation Area</option>
<option value="recipient_7">Other</option>
</select>
<?-- <option>Please Select</option>
<option value =>General Enquiries</option>
<option>Hall Hire</option>
<option>Marquee Hire</option>
<option>Parish Church</option>
<option>Parish Council</option>
<option>Recreation Area</option>
<option>Other</option>
</select> //-->
</div></td>
</tr>
<tr>
<td width="50%" height="127"><div align="center">Enquiry Details:</div></td>
<td width="50%"><div align="center">
<textarea name="Questions" cols="40%" rows="4" id="Questions"></textarea>
</div></td>
</tr>
<tr>
<td width="50%"><div align="center">
<input name="contactSubmit" type="submit" id="contactSubmit" onClick="MM_validateForm('Name','','R','Telephone','','RisNum','Email','','NisEmail','Questions','','R');return document.MM_returnValue" value="Submit">
</div></td>
<td width="50%"><div align="center">
<input name="ContactReset" type="reset" id="ContactReset" value="Reset">
</div></td>
</tr>
</table>
<p> </p>
<p> </p>
</form>
<p align="center"> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
</body>
</html>
[/code]
[code=php]
<?php
/* Error Checking */
error_reporting(E_ALL | E_NOTICE); // Kinds of errors to show
ini_set('display_errors', '1'); // turn on display at the client to display the messages
/* Email Variables */
$emailSubject = 'website_process';
$recipients = array(
'recipient_1' => '[email protected]',
'recipient_2' => '[email protected]',
'recipient_3' => '[email protected]'
'recipient_4' => '[email protected]',
'recipient_5' => '[email protected]',
'recipient_6' => '[email protected]',
'recipient_7' => '[email protected]'
/*General Enquiries => '[email protected]',
Hall Hire => '[email protected]',
Marquee Hire => '[email protected]'
Parish Church => '[email protected]',
Parish Council => '[email protected]',
Recreation Area => '[email protected]',
Other => '[email protected]'*/
);
$my_email = $recipients[$_REQUEST['Nature']];
/* Data Variables */
$Name = $_POST['Name'];
$Telephone = $_POST['Telephone'];
$Email = $_POST['Email'];
$Nature = $_POST['Nature'];
$Questions = $_POST['Questions'];
/* Email Content*/
$body = <<<EOD
<br><hr><br>
Name: $Name <br>
Telephone: $Telephone <br>
Email: $Email <br>
recipient: $recipient <br>
Questions: $Questions <br>
EOD;
$headers = "From: $Emailrn";
$headers .= "Content-type: text/htmlrn";
echo "my email is $my_email<br>";
echo "subject is $emailSubject<br>";
echo "body is $body<br>";
echo "headers are $headers<br>";
$success = mail($my_email, $emailSubject, $body,
$headers);
/* Results HTML */
$theResults = <<<EOD
<html>
<head>
<title>sent message</title>
<meta http-equiv="refresh" content="3;URL=http://example.com/index.html">
<style type="text/css">
body {
background-color: #444;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 20px;
color: #fec001;
padding-top: 200px;
width: 800px;
margin: auto;
text-align: center;
}
</style>
</head>
<body>
<div>Thank you for your enquiry. Your message has been sent and we will respond as soon as possible.</div>
</body>
</html>
EOD;
echo "$theResults";
?>
[/code]
It looks as if it trying to run the php. The URL is http:/www.example.com/website_process.php
That is the name of my php script.[/QUOTE]
[code=html]
<html>
<head>
<title>Welcome to Example - Contact Us</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_validateForm() { //v4.0
var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
if (val) { nm=val.name; if ((val=val.value)!="") {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p<1 || p==(val.length-1)) errors+='- '+nm+' - must contain an e-mail address.n';
} else if (test!='R') { num = parseFloat(val);
if (isNaN(val)) errors+='- '+nm+' - Please enter just a number. Do not enter spaces or dashes etcn';
if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.n';
} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' - Please provide details.n'; }
} if (errors) alert('The following error(s) occurred:n'+errors);
document.MM_returnValue = (errors == '');
}
//-->
</script>
</head>
<body bgcolor="#FFFFFF" background="goldmold.jpg">
<div id="Layer1" style="position:absolute; width:207px; height:42px; z-index:3; left: 10px; top: 19px;"><font size="6" face="Calligraph421 BT"><strong>Welcome
to <font size="7">Example</font></strong></font></div>
<h1> </h1>
<p align="center"><font size="+4"><strong>Contact Us</strong></font></p>
<hr>
<div align="right"><font size="-1"><strong><a href="index.html" style="text-decoration = None"><font color="#000000" face="Calligraph421 BT">Return
to Home Page</font></a></strong></font></div>
<blockquote>
<blockquote>
<blockquote>
<p align="center"><font size="+1" face="Calligraph421 BT"><strong>For any
enquiries relating to the Village Hall, please either telephone the Bookings
Secretary between 08:00 and 20:00 Monday to Friday on 0845-643-0000, or
<a href="mailto:[email protected]"><img src="emailbutton.jpg" width="70" height="20" border="0"></a>
her with any questions.</strong></font></p>
</blockquote>
</blockquote>
</blockquote>
<p align="center"><strong><font size="+1" face="Calligraph421 BT">Alternatively,
or for other village matters, please complete and submit the short form below,
and we will respond as soon as possible</font></strong></p>
<form action="website_process.php" method="post" enctype="multipart/form-data" name="Contactform" id="Contactform">
<table width="50%" border="1" align="center">
<tr>
<td width="50%" height="64"><div align="center">Full Name:</div></td>
<td width="50%"><div align="center">
<input name="Name" type="text" id="Name" size="48%">
</div></td>
</tr>
<tr>
<td width="50%" height="64"><div align="center">Telephone No.</div></td>
<td width="50%"><div align="center">
<input name="Telephone" type="text" id="Telephone" size="48%">
</div></td>
</tr>
<tr>
<td width="50%" height="67"><div align="center">Email:</div></td>
<td width="50%"><div align="center">
<input name="Email" type="text" id="Email" size="48%">
</div></td>
</tr>
<tr>
<td width="50%" height="56"><div align="center">Nature of your Enquiry ?</div></td>
<td width="50%"><div align="center">
<select name="Nature" size="1" id="Nature">
<option>Please Select</option>
<option value="General_Enquiries">General Enquiries</option>
<option value="Hall_Hire">Hall Hire</option>
<option value="Marquee_Hire">Marquee Hire</option>
<option value="Parish_Church">Parish Church</option>
<option value="Parish_Council">Parish Council</option>
<option value="Recreation_Area">Recreation Area</option>
<option value="Social_Club">Social Club</option>
<option value="Other">Other</option>
</select>
</div></td>
</tr>
<tr>
<td width="50%" height="127"><div align="center">Enquiry Details:</div></td>
<td width="50%"><div align="center">
<textarea name="Questions" cols="40%" rows="4" id="Questions"></textarea>
</div></td>
</tr>
<tr>
<td width="50%"><div align="center">
<input name="contactSubmit" type="submit" id="contactSubmit" onClick="MM_validateForm('Name','','R','Telephone','','RisNum','Email','','NisEmail','Questions','','R');return document.MM_returnValue" value="Submit">
</div></td>
<td width="50%"><div align="center">
<input name="ContactReset" type="reset" id="ContactReset" value="Reset">
</div></td>
</tr>
</table>
<p> </p>
<p> </p>
</form>
<p align="center"> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
</body>
</html>
[/code]
[code=php]
<?php
/* Error Checking */
error_reporting(E_ALL | E_NOTICE);
ini_set('display_errors', '1');
/* Email Variables */
$emailSubject = 'Enquiry from Example Website';
$recipients = array(
General_Enquiries => '[email protected]',
Hall_Hire => '[email protected]',
Marquee_Hire => '[email protected]'
Parish_Church => '[email protected]',
Parish_Council => '[email protected]',
Recreation_Area => '[email protected]',
Social_Club => '[email protected]',
Other => '[email protected]'
);
$my_email = $recipients[$_POST['Nature']];
/* Data Variables */
$Name = $_POST['Name'];
$Telephone = $_POST['Telephone'];
$Email = $_POST['Email'];
$Nature = $_POST['Nature'];
$Questions = $_POST['Questions'];
/* Email Content*/
$body = <<<EOD
<br><hr><br>
You have an enquiry from the Example Website <br>
<br><hr><br>
Name: $Name <br>
Telephone: $Telephone <br>
Email: $Email <br>
Nature of Enquiry: $Nature <br>
Enquiry Details: $Questions <br>
EOD;
$headers = "From: $Emailrn";
$headers .= "Content-type: text/htmlrn";
$success = mail($my_email, $emailSubject, $body,
$headers);
/* Results */
$theResults = <<<EOD
<html>
<head>
<title>sent message</title>
<meta http-equiv="refresh" content="5;URL=http://example.com/index.html">
<style type="text/css">
body {
background-color: #444;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 20px;
color: #fec001;
padding-top: 200px;
width: 800px;
margin: auto;
text-align: center;
}
</style>
</head>
<body>
<div>Thank you for your enquiry. Your message has been sent and we will respond as soon as possible.</div>
</body>
</html>
EOD;
echo "$theResults";
?>
[/code]
[code=php]
function html_ready($value,$options=ENT_QUOTES,$charcode='UTF-8')
{
return htmlspecialchars($value,$options,$charcode);
}
[/code]
[code=php]
/* Data Variables */
$Name = $_POST['Name'];
$Telephone = $_POST['Telephone'];
$Email = $_POST['Email'];
$Nature = $_POST['Nature'];
$Questions = $_POST['Questions'];
/* Email Content*/
$body = <<<EOD
<br><hr><br>
You have an enquiry from the Example Website <br>
<br><hr><br>
Name: $Name <br>
Telephone: $Telephone <br>
Email: $Email <br>
Nature of Enquiry: $Nature <br>
Enquiry Details: $Questions <br>
EOD;
[/code]
[code=php]
$Name = html_ready($_POST['Name']);
[/code]
0.1.9 — BETA 5.26