|
|
|
|
![]() ![]() |
Feb 17 2006, 06:04 PM
Post
#1
|
|
|
Member [Level 1] ![]() ![]() ![]() ![]() Group: Members Posts: 58 Joined: 31-January 06 Member No.: 17,937 |
Hello,
I get the following error: Parse error: syntax error, unexpected T_STRING in /usr/local/psa/home/vhosts/club-amigos.co.uk/httpdocs/contact.php on line 44 when l run the following script: Any help would be appreciated. CODE <?php /* PHP Form Mailer - phpFormMailer v2.1, last updated 30th Nov 2005 - check back often for updates! (easy to use and more secure than many cgi form mailers) FREE from: www.TheDemoSite.co.uk Should work fine on most Unix/Linux platforms */ // ------- three variables you MUST change below ------------------------------------------------------- $valid_ref1="http://adly3000.trap17.com/contact_test.html";// chamge "Your--domain" to your domain $valid_ref2="http://adly3000.trap17.com/contact_test.html";// chamge "Your--domain" to your domain $replyemail="EMAIL REMOVED - Send PM to This User Instead";//change to your email address // ------------------------------------------------------------ //clean input in case of header injection attempts! function clean_input_4email($value, $check_all_patterns = true) { $patterns[0] = '/content-type:/'; $patterns[1] = '/to:/'; $patterns[2] = '/cc:/'; $patterns[3] = '/bcc:/'; if ($check_all_patterns) { $patterns[4] = '/\r/'; $patterns[5] = '/\n/'; $patterns[6] = '/%0a/'; $patterns[7] = '/%0d/'; } //NOTE: can use str_ireplace as this is case insensitive but only available on PHP version 5.0. return preg_replace($patterns, "", strtolower($value)); } $name = clean_input_4email($_POST["name"]); $email = clean_input_4email($_POST["email"]); $thesubject = clean_input_4email($_POST["thesubject"]); $themessage = clean_input_4email($_POST["themessage"], false); $error_msg='ERROR - not sent. Try again.'; $success_sent_msg='{ print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html\">"; } // email variable not set - load $valid_ref1 page if (!isset($_POST['email'])) { echo "<script language=\"JavaScript\"><!--\n "; echo "top.location.href = \"$valid_ref1\"; \n// --></script>"; exit; } $ref_page=$_SERVER["HTTP_REFERER"]; $valid_referrer=0; if($ref_page==$valid_ref1) $valid_referrer=1; elseif($ref_page==$valid_ref2) $valid_referrer=1; if(!$valid_referrer) { echo "<script language=\"JavaScript\"><!--\n alert(\"$error_msg\");\n"; echo "top.location.href = \"$valid_ref1\"; \n// --></script>"; exit; } $themessage = "name: $name \nQuery: $themessage"; [code]<?php /* PHP Form Mailer - phpFormMailer v2.1, last updated 30th Nov 2005 - check back often for updates! (easy to use and more secure than many cgi form mailers) FREE from: www.TheDemoSite.co.uk Should work fine on most Unix/Linux platforms */ // ------- three variables you MUST change below ------------------------------------------------------- $valid_ref1="http://www.club-amigos.co.uk/contact_test.html";// chamge "Your--domain" to your domain $valid_ref2="http://www.club-amigos.co.uk/contact_test.html";// chamge "Your--domain" to your domain $replyemail="EMAIL REMOVED - Send PM to This User Instead";//change to your email address // ------------------------------------------------------------ //clean input in case of header injection attempts! function clean_input_4email($value, $check_all_patterns = true) { $patterns[0] = '/content-type:/'; $patterns[1] = '/to:/'; $patterns[2] = '/cc:/'; $patterns[3] = '/bcc:/'; if ($check_all_patterns) { $patterns[4] = '/\r/'; $patterns[5] = '/\n/'; $patterns[6] = '/%0a/'; $patterns[7] = '/%0d/'; } //NOTE: can use str_ireplace as this is case insensitive but only available on PHP version 5.0. return preg_replace($patterns, "", strtolower($value)); } $name = clean_input_4email($_POST["name"]); $email = clean_input_4email($_POST["email"]); $thesubject = clean_input_4email($_POST["thesubject"]); $themessage = clean_input_4email($_POST["themessage"], false); $error_msg='ERROR - not sent. Try again.'; $success_sent_msg='{ print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html\">"; } // email variable not set - load $valid_ref1 page if (!isset($_POST['email'])) { echo "<script language=\"JavaScript\"><!--\n "; echo "top.location.href = \"$valid_ref1\"; \n// --></script>"; exit; } $ref_page=$_SERVER["HTTP_REFERER"]; $valid_referrer=0; if($ref_page==$valid_ref1) $valid_referrer=1; elseif($ref_page==$valid_ref2) $valid_referrer=1; if(!$valid_referrer) { echo "<script language=\"JavaScript\"><!--\n alert(\"$error_msg\");\n"; echo "top.location.href = \"$valid_ref1\"; \n// --></script>"; exit; } $themessage = "name: $name \nQuery: $themessage"; mail("$replyemail", "$thesubject", "$themessage", "From: $email\nReply-To: $email"); mail("$email", "Receipt: $thesubject", "$replymessage", "From: $replyemail\nReply-To: $replyemail"); echo $success_sent_msg; /* PHP Form Mailer - phpFormMailer (easy to use and more secure than many cgi form mailers) FREE from: www.TheDemoSite.co.uk */ ?> |
|
|
|
Feb 17 2006, 06:39 PM
Post
#2
|
|
|
A computer once beat me at chess, but it was no match for me at kick boxing. ![]() Group: [MODERATOR] Posts: 3,882 Joined: 24-July 05 From: In Trouble Again... still? Member No.: 9,787 ![]() |
This might not be the solution, but I noticed that the following post array element uses only single quotes while the ones above this line (which didn't error) use double quotes to contain the array element name. And the ones below it also use double quotes, too, so maybe I'm on to something here.
Try changing this code to double quotes. CODE if (!isset($_POST['email'])) I am just learning php, so I might be wrong on this. Post back if this doesn't work and you still need a hand. |
|
|
|
Feb 18 2006, 04:56 AM
Post
#3
|
|
|
Privileged Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 874 Joined: 30-July 04 Member No.: 246 |
It makes no difference whether you use double or single quotes when referencing indexes in an array. In fact, unless you absolutely have to, I would recommend using single quotes wherever possible (and not just when working with arrays, but in all aspects of PHP), as it's processed faster.
Anyway, as with most errors in PHP, the actual problem is not on the mentioned line, but prior to that. Take a look at lines 38 to 40: CODE $success_sent_msg='{ print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html\">"; } I think you'll find therein lies your error (note the opening quote, but lack of a closing one - I'm also not sure why the squigly braces have been added). I took a quick look at the original script, and the equivalent code was: CODE $success_sent_msg='<p align="center"><strong> </strong></p> <p align="center"><strong>Your message has been successfully sent to us<br> </strong> and we will reply as soon as possible.</p> <p align="center">A copy of your query has been sent to you.</p> <p align="center">Thank you for contacting us.</p>'; Hope that helps. |
|
|
|
Feb 19 2006, 10:46 PM
Post
#4
|
|
|
Member [Level 1] ![]() ![]() ![]() ![]() Group: Members Posts: 58 Joined: 31-January 06 Member No.: 17,937 |
thanks all.that is helping me to the right way thanks.
|
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 25th July 2008 - 10:28 PM |