Hi All,
I'm looking for some help using the code below. I just want a simple redirect to happen after the form is submitted however no matter what I do I can't get it to redirect. The page just refreshes. Any help would be greatly appreciated! I've bolded values that I changed for posting here - they are correct in the actual site code. I also just changed the redirect to google.com for example purposes.
<?php
// START NECESSARY MODIFICATIONS
// your name
$recipientname = "[B]NAME[/B]";
// your email
$recipientemail = "[B]EMAIL@EMAIL.COM[/B]";
// subject of the email sent to you
$subject = "[B]SUBJECTHERE[/B]";
// send an autoresponse to the user?
$autoresponse = "yes";
// subject of autoresponse
$autosubject = "Thank you!";
// autoresponse message
$automessage = "[B]Thanks you![/B]";
// END NECESSARY MODIFICATIONS
?>
</head>
<body>
<?php
if($_POST['submitform']) {
$Name = $HTTP_POST_VARS['textfield'];
$Email = $HTTP_POST_VARS['textfield2'];
// 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 = "[B]SUBMITFORM FOR[/B] $recipientname:
Name: $Name
Email: $Email
-----------------------------
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>");
}
header("Location: http://www.google.com");
}
}
else {
?>
<div class="fatlossoptin">
<div class="fatlossoptincontent">
<form name="contactform" action="<?php echo $PHP_SELF; ?>" method="post">
<input type="hidden" name="require" value="Name,Email">
<br>
<table width="240" border="0" cellspacing="0" cellpadding="5" align="center">
<tr>
<td width="71">Name:</td>
<td width="169">
<input type="text" name="textfield" id="NAMEIDHERE" class="text" />
</td>
</tr>
<tr>
<td>Email:</td>
<td><input type="text" name="textfield2" id="EMAILIDHERE" class="text" /></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" class="button" value=""/></td>
</tr>
</table>
</form>
</div>
</div>
<?php } ?>