I am rather new too PHP and i found a email form for a website on another site and edited slightly to suit my needs better, however it will not send to the specified email, it redirects on the same page with an error. I just can't seem to figure out what is causing it
Any help would be greatly appreciated!
<html>
<head>
<title>BLANK</title>
<link rel="stylesheet" href="style.css" type="text/css" media="screen" />
<?php
// your name
$recipientname = "BLANK";
// your email
$recipientemail = "BLANK";
// subject of the email sent to you
$subject = "Contact form for $recipientname";
// send an autoresponse to the user?
$autoresponse = "yes";
// subject of autoresponse
$autosubject = "Thank you for your message.";
// autoresponse message
$automessage = "We have received your message and will get back to you as soon as possible.";
// thankyou displayed after the user clicks "submit"
$thanks = "Thank you for contacting us.<br>We will get back to you as soon as possible.<br>";
?>
</head>
<body>
<div id="mainwrap">
<?php include("header.php"); ?>
<?php include("leftnav.php"); ?>
<div id="contentwrap">
<div id="breadcrumb"></div>
<div id="content">
<h2>Still Under Development...</h2>
<?php
if($_POST['submitform']) {
$Name = $HTTP_POST_VARS['Name'];
$Email = $HTTP_POST_VARS['Email'];
$Comments = $HTTP_POST_VARS['Comments'];
// check required fields
$dcheck = explode(",",$require);
while(list($check) = each($dcheck)) {
if(!$$dcheck[$check]) {
$error .= "Missing $dcheck[$check]<br>";
}
}
// check email address
if ((!ereg(".+\@.+\..+", $Email)) || (!ereg("^[a-zA-Z0-9_@.-]+$", $Email))){
$error .= "Invalid email address<br>";}
// display errors
if($error) {
?>
<b>Error</b><br>
<?php echo $error; ?><br>
<a href="#" onClick="history.go(-1)">try again</a>
<?php
}
else
{
$browser = $HTTP_USER_AGENT;
$ip = $REMOTE_ADDR;
// format message
$message = "Online-Form Response for $recipientname:
Name: $Name
Email: $Email
Comments: $Comments
-----------------------------
Browser: $browser
User IP: $ip";
// send mail and print success message
mail($recipientemail,"$subject","$message","From: $Name <$Email>");
if($autoresponse == "yes") {
$autosubject = stripslashes($autosubject);
$automessage = stripslashes($automessage);
mail($Email,"$autosubject","$automessage","From: $recipientname <$recipientemail>");
}
echo "$thanks";
}
}
else {
?>
<form name="contactform" action="<?php echo $PHP_SELF; ?>" method="post">
<input type="hidden" name="require" value="Name,Email,Comments">
<br>
Name <br>
<input name="Name" size="25">
<br>
<br>
E-mail<br>
<input name="Email" size="25">
<br>
<br>
Comments<br>
<textarea name="Comments" rows="5" cols="35"></textarea>
<br>
<br>
<input type="submit" value="Submit" name="submitform">
<input type="reset" value="Reset" name="reset">
</p>
<br>
</form>
<?php } ?>
</div>
</div>
<?php include("footer.php"); ?>
</div>
</body>
</html>
This is the contactus.php page which is the main page with the form layout etc.(Email etc blanked out for my privacy)
This is what it links to on the same page, i just can't seem to fix it no matter what i do !
Please help
Thanks in advance!