Made up this script to take the contact form details and to send a copy to the user and a copy to the administrator (still to add admin email send)
Had a couple of errors but cleared those out. When I click the submit button it just doesnt do anything.
Ive used the same sections of code on my mailing list scripts and thats all working. I just cant see where I've gone wrong.
Here is my code:
<?php include "header.php"; ?>
<h1>
Contact Us
</h1>
<hr>
<br>
<p>Please fill in the form below</p>
<h3>Contact Form</h3>
<table width="579">
<tr>
<td width="124" valign="top">First Name:<br> <br> </td>
<td width="270"><input name="fname" type="text" value="" size="48" maxlength="255">
<br> <br> </td>
</tr>
<tr>
<td width="124" valign="top">Last Name:<br> <br> </td>
<td width="270"><input name="lname" type="text" value="" size="48" maxlength="255">
<br> <br> </td>
</tr>
<tr>
<td height="63" valign="top">Your email address:</td>
<td><p>
<input name="email" type="text" value="" size="48" maxlength="255">
<br>
<br>
<br>
</p></td>
</tr>
<tr>
<td valign="top">Your Comments:</td>
<td><textarea name="comments" cols="37" rows="6"></textarea>
<br> <br> </td>
</tr>
<tr>
<td valign="top">Verification:</td>
<td>
<?php
// Display Recaptcha
require_once('./mailer/recaptchalib.php');
$publickey = "key_here";
echo recaptcha_get_html($publickey);
?>
</td>
</tr>
<tr>
<td valign="top"> </td>
<td><p> <br>
<input type="submit" name="submit" value="Submit">
<input type="reset" name="submit2" value="Reset">
</p></td>
</tr>
</table>
<p> </p>
<p> </p>
<p><br></div>
</p>
<?php
//image header
$image = "http://www.example.com/images/emailheader.jpg";
//form submitted
if($_POST["action"]=="submit"){
//recaptcha image verification
require_once('recaptchalib.php');
$privatekey = "key_here";
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
?>
<h5>
<br>
The image verification wasn't entered correctly. Go back and try it again.
<br>
<br>
<a href="javascript: history.go(-1)">< < Go Back</a>
</h5>
</div>
<?php
//include footer if there is an error
include "./footer.php";
die("");
}else
//set variable names
$name = $_POST["fname"];
$lname = $_POST["lname"];
$email = $_POST["email"];
$comments = $_POST["comments"];
//subscribe
if($_POST["action"]=="submit"){
//check if name is long enough
if(strlen($name)<3){
?>
<h5>
<br>
First name must consist of at least 3 characters.
<br>
<br>
<a href="javascript: history.go(-1)">< < Go Back</a>
</h5>
<?php
//check if name is long enough
}else if(strlen($lname)<3){
?>
<h5>
<br>
Last name must consist of at least 3 characters.
<br>
<br>
<a href="javascript: history.go(-1)">< < Go Back</a>
</h5>
<?php
//check if email is valid
}else if(!eregi("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,3}$",$email)){
?>
<h5>
<br>
Email address is not valid.
<br>
<br>
<a href="javascript: history.go(-1)">< < Go Back</a>
</h5>
<?php
//send confirmation email
$to = $_POST["email"];
$subject = "Reef Zone Aquatics Contact Form";
$message = "
<html>
<body>
<div align='center'><img src='http://www.example.com/images/emailheader.jpg'>
<br>
<br>
<font size='6' font face='Calibri'>
<strong>
Contact Us
</strong>
</font>
<br>
<br>
<font size='3' font face='Calibri'>
<h5>Contact Us form submission</h5>
<br>
<br>
Hi $name $lname, thankyou for contacting Reef Zone Aquatics.
<br>
<br>
We endevour to reply to you on the following email address ( $email ) in 3 working days.
<br>
<br>
Yours, Reef Zone Aquatics
<br>
<br>
----------------------------------------------------------------------------------------------------
<br>
<font size='2' font face='Calibri'>
You receive this email because you have contact Reef Zone Aquatics.
<font size='1' font face='Calibri'>
* * * This email was sent from an automated system * * *
</font>
<br>
</font>
</div>
</body>
</html>
";
// Set content-type
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
// More headers
$headers .= 'From: <support@example.com>' . "\r\n";
// Send mail line
mail($to,$subject,$message,$headers);
//error occurred
if(@mysql_error()){
?>
<h5>
<br>
An unknown error occurred. Please try again later.
<br>
<br>
<a href="javascript: history.go(-1)">< < Go Back</a>
</h5>
<?php
//successful
}else{
?>
<h5>
<br>
Congratulations! Your comments have been sent to an administrator!
<br>
<a href="javascript: history.go(-1)">< < Go Back</a>
</h5>
</div>
<?php
} } } }
// Display Footer
include "footer.php";
?>