Hey guys!
Okay, backs up against the wall - just published client's site to find that form page does not work. (EEK - they'll be wondering why!)
Actually, it does send the form contents - its just that it won't take me to my thank you for sending this form page.
This is what I get:
Warning: Cannot modify header information - headers already sent by (output started at /misc/13/929/722/123/user/web/bodmincommunitychurch.com/Email_Processor/BCC_email_processor_1.php:1) in /misc/13/929/722/123/user/web/bodmincommunitychurch.com/Email_Processor/BCC_email_processor_1.php on line 143
I have taken a look on other websites for help and removed all white spaces from ?> tags etc on the page mentioned above.
Here is the code of the php page in question: (I have removed the recaptcha private key code between the ""). The form code was free from another website so I can't say I understand it I am afraid...
<?php
require_once('recaptchalib.php');
$privatekey = "";
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
die ("The reCAPTCHA wasn’t entered correctly. Go back and try it again." .
"(reCAPTCHA said: " . $resp->error . ")");
}
?>
<?php
/*
Step 2:
Enter your email address.
Enter the email address below to send the contents of the form to. You can enter more than one email address separated by commas, like so: $my_email = "info@example.com"; or $my_email = "bob@example.com,sales@example.co.uk,jane@example.com";
*/
$my_email = "info@cornishsands.co.uk";
//$my_email = "testmail@localhost.com";
/*
Enter the continue link to offer the user after the form is sent. If you do not change this, your visitor will be given a continue link to your homepage.
If you do change it, remove the "/" symbol below and replace with the name of the page to link to, eg: "mypage.htm" or "http://www.elsewhere.com/page.htm"
*/
$continue = "thankyou.html";
/*
Step 3:
Save this file (emailProcessor.php) and upload it together with your webpage containing the form to your webspace. IMPORTANT - The file name is case sensitive! You must save it exactly as it is named above!
THAT'S IT, FINISHED!
You do not need to make any changes below this line.
*/
$errors = array();
// Remove $_COOKIE elements from $_REQUEST.
if(count($_COOKIE)){foreach(array_keys($_COOKIE) as $value){unset($_REQUEST[$value]);}}
// Validate email field.
if(isset($_REQUEST['email']) && !empty($_REQUEST['email']))
{
$_REQUEST['email'] = trim($_REQUEST['email']);
if(substr_count($_REQUEST['email'],"@") != 1 || stristr($_REQUEST['email']," ")){
$errors[] = "Email address is invalid";
}else{
$exploded_email = explode("@",$_REQUEST['email']);
if(empty($exploded_email[0]) || strlen($exploded_email[0]) > 64 || empty($exploded_email[1])){ $errors[] = "Email address is invalid";
}else{
if(substr_count($exploded_email[1],".") == 0){
$errors[] = "Email address is invalid";
}else{
$exploded_domain = explode(".",$exploded_email[1]);
if(in_array("",$exploded_domain)){
$errors[] = "Email address is invalid";
}else{
foreach($exploded_domain as $value){
if(strlen($value) > 63 || !preg_match('/^[a-z0-9-]+$/i',$value)){
$errors[] = "Email address is invalid";
break;
}}}}}}
}
// Check referrer is from same site.
if(!(isset($_SERVER['HTTP_REFERER']) && !empty($_SERVER['HTTP_REFERER']) && stristr($_SERVER['HTTP_REFERER'],$_SERVER['HTTP_HOST']))){$errors[] = "You must enable referrer logging to use the form";}
// Check for a blank form.
function recursive_array_check_blank($element_value)
{
global $set;
if(!is_array($element_value)){if(!empty($element_value)){$set = 1;}}
else
{
foreach($element_value as $value){if($set){break;} recursive_array_check_blank($value);}
}
}
recursive_array_check_blank($_REQUEST);
if(!$set){$errors[] = "You cannot send a blank form";}
unset($set);
// Display any errors and exit if errors exist.
if(count($errors)){
foreach($errors as $value){
print "$value<br>";
}
echo('Return to form <a href="BCC_Form.php">Click Here</a>');
exit;}
if(!defined("PHP_EOL")){define("PHP_EOL", strtoupper(substr(PHP_OS,0,3) == "WIN") ? "\r\n" : "\n");}
// Build message.
function build_message($request_input){if(!isset($message_output)){$message_output ="";}if(!is_array($request_input)){$message_output = $request_input;}else{foreach($request_input as $key => $value){if(!empty($value)){if(!is_numeric($key)){$message_output .= str_replace("_"," ",ucfirst($key)).": ".build_message($value).PHP_EOL.PHP_EOL;}else{$message_output .= build_message($value).", ";}}}}return rtrim($message_output,", ");}
$message = build_message($_REQUEST);
$message = $message . PHP_EOL.PHP_EOL."-- ".PHP_EOL."Thank you for sending this information. We will be in touch soon.";
$message = stripslashes($message);
$subject = "Form Mail";
$subject = stripslashes($subject);
$from_name = "";
if(isset($_REQUEST['First_name']) && !empty($_REQUEST['First_name'])){$from_name = stripslashes($_REQUEST['First_name']);}
$headers = "From: {$from_name} <{$_REQUEST['email']}>";
mail($my_email,$subject,$message,$headers);
header("Location: http://www.bodmincommunitychurch.com/Email_Processor/thankyou.html");
?>
Can anyone offer suggestions please? Please bear in mind I don't know php so I would be grateful if you could be clear in your instructions
Best wishes, T





Bookmarks