Need Help

Posts 1–9 of 9 · Page 1 of 1
Need Help
Hello
I downloaded a contact form.. but it tells me it got errors
I got this error = ( ! ) Parse error: syntax error, unexpected $end in E:\wamp\www\back52\lite_process.php on line 76 // at the bottom!!!

My scripts =
Code:
<?php
// URL: www.freecontactform.com
// Version: FreeContactForm Lite V1.1
// Copyright (c) 2010 Stuart Cochrane <stuartc1@gmail0.com>
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
if(isset($_POST['Email_Address'])) {
	
	include 'lite_settings.php';
	
	if($email_to == "youremailaddress@yourdomain.com") {
		die("This message is for the Webmaster. Please enter your email address into the file 'lite_settings.php'");
	}
	
	function died($error) {
		echo "Sorry, but there were error(s) found with the form you submitted. ";
		echo "These errors appear below.<br /><br />";
		echo $error."<br /><br />";
		echo "Please go back and fix these errors.<br /><br />";
		die();
	}
	
	if(!isset($_POST['Full_Name']) ||
		!isset($_POST['Email_Address']) ||
		!isset($_POST['Telephone_Number']) ||
		!isset($_POST['Your_Message'])) {
		died('We are sorry, but there appears to be a problem with the form you submitted.');		
	}
	
	$full_name = $_POST['Full_Name']; // required
	$email_from = $_POST['Email_Address']; // required
	$telephone = $_POST['Telephone_Number']; // not required
	$comments = $_POST['Your_Message']; // required
	
	$error_message = "";
	$email_exp = "^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$";
  if(!eregi($email_exp,$email_from)) {
  	$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
  }
  if(strlen($full_name) < 2) {
  	$error_message .= 'Your Name does not appear to be valid.<br />';
  }
  if(strlen($comments) < 2) {
  	$error_message .= 'The Comments you entered do not appear to be valid.<br />';
  }
  
  if(strlen($error_message) > 0) {
  	died($error_message);
  }
	$email_message = "Form details below.\r\n";
	
	function clean_string($string) {
	  $bad = array("content-type","bcc:","to:","cc:","href");
	  return str_replace($bad,"",$string);
	}
	
	$email_message .= "Full Name: ".clean_string($full_name)."\r\n";
	$email_message .= "Email: ".clean_string($email_from)."\r\n";
	$email_message .= "Telephone: ".clean_string($telephone)."\r\n";
	$email_message .= "Message: ".clean_string($comments)."\r\n";
	
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@Mail($email_to, $email_subject, $email_message, $headers);
header("Location: $thankyou");
?>
<script>location.replace('<?php echo $thankyou;?>')</script>
<?
}     // THIS IS THE PROBLEM!!! RIGHT OVER THOSE LAST LINES? but if i delete them i got an error to.. please help!!
?>
If you need more.. tell me..

Please help me it's for a school project!
thx
<?
} // THIS IS THE PROBLEM!!! RIGHT OVER THOSE LAST LINES? but if i delete them i got an error to.. please help!!
?>


<? is not an opening php tag.

<?php

?>

is the way it should be.

However you could just change this:

Code:
@Mail($email_to, $email_subject, $email_message, $headers);
header("Location: $thankyou");
?>
<script>location.replace('<?php echo $thankyou;?>')</script>
<?
}     // THIS IS THE PROBLEM!!! RIGHT OVER THOSE LAST LINES? but if i delete them i got an error to.. please help!!
?>
To this:

Code:
@Mail($email_to, $email_subject, $email_message, $headers);
header("Location: $thankyou");
echo "<script>location.replace('".$thankyou."')</script>";
}     // THIS IS THE PROBLEM!!! RIGHT OVER THOSE LAST LINES? but if i delete them i got an error to.. please help!!
?>
@[MGPH]Jason: "<? is in fact an opening PHP tag... however, is not supported by all browsers. "<?PHP" opening tag is supported by all browsers, so it is recommended... try adding an ELSE or ELSEIF, if that doesnt work - give me some time (like 24 hours) to figure it out and i guarantee youll get it resolved.

What your script is saying is if the condition is true, then do this....... and your main script comes in. But what if the condition is not true? If the condition is not true, it has nothing to do, since you have not defined anything.
Quote Originally Posted by xARGONx View Post
@[MGPH]Jason: "<? is in fact an opening PHP tag... however, is not supported by all browsers. "<?PHP" opening tag is supported by all browsers, so it is recommended... try adding an ELSE or ELSEIF, if that doesnt work - give me some time (like 24 hours) to figure it out and i guarantee youll get it resolved.

What your script is saying is if the condition is true, then do this....... and your main script comes in. But what if the condition is not true? If the condition is not true, it has nothing to do, since you have not defined anything.
The expected $end is usually a parsing error due to failure to find (or having an extra) closing brace. Could just be that his default browser doesn't support the shorthand <?
@xARGONx @Jason

The browser doesn't handle php code, the server does. And <? does work like <?php provided that short_open_tag or w/e is set to true.

Also, this works without problems over here (cleaned up with npp), what errors do you get?:

[highlight=php]
<?php
// URL: Free Contact Form scripts, email forms. FreeContactForm.com
// Version: FreeContactForm Lite V1.1
// Copyright (c) 2010 Stuart Cochrane <stuartc1@gmail0.com>
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
if(isset($_REQUEST['Email_Address'])) {
include 'lite_settings.php';
if($email_to == 'youremailaddress@yourdomain.com') {
die('This message is for the Webmaster. Please enter your email address into the file "lite_settings.php"');
}
function died($error) {
echo 'Sorry, but there were error(s) found with the form you submitted. ';
echo 'These errors appear below.<br /><br />';
echo $error.'<br /><br />';
echo 'Please go back and fix these errors.<br /><br />';
die();
}
if(!isset($_REQUEST['Full_Name']) ||
!isset($_REQUEST['Email_Address']) ||
// !isset($_REQUEST['Telephone_Number']) || not required?
!isset($_REQUEST['Your_Message'])) {
died('We are sorry, but there appears to be a problem with the form you submitted.');
}
$full_name = $_REQUEST['Full_Name']; // required
$email_from = $_REQUEST['Email_Address']; // required
$telephone = $_REQUEST['Telephone_Number']; // not required
$comments = $_REQUEST['Your_Message']; // required
$error_message = '';
if(!preg_match('/^[[:alnum:]-_.]+@[[:alnum:]-_.]+\.[a-z]{2,4}$/i', $email_from)) {
$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
}
if(strlen($full_name) < 2) {
$error_message .= 'Your Name does not appear to be valid.<br />';
}
if(strlen($comments) < 2) {
$error_message .= 'The Comments you entered do not appear to be valid.<br />';
}
if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = 'Form details below.'."\r\n";
function clean_string($string) {
$bad = array('content-type', 'bc:', 'to:', 'cc:', 'href');
return str_replace($bad, '', $string);
}
$email_message .= 'Full Name: '.clean_string($full_name)."\r\n";
$email_message .= 'Email: '.clean_string($email_from)."\r\n";
$email_message .= 'Telephone: '.clean_string($telephone)."\r\n";
$email_message .= 'Message: '.clean_string($comments)."\r\n";
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@Mail($email_to, $email_subject, $email_message, $headers);
header('Location: '.$thankyou);
}
?>
[/highlight]

PS: fml, REQUEST should be POST, I cbf to send post values so I just used get
Quote Originally Posted by Alen View Post
@xARGONx @Jason

The browser doesn't handle php code, the server does. And <? does work like <?php provided that short_open_tag or w/e is set to true.

Also, this works without problems over here (cleaned up with npp), what errors do you get?:

[highlight=php]
<?php
// URL: Free Contact Form scripts, email forms. FreeContactForm.com
// Version: FreeContactForm Lite V1.1
// Copyright (c) 2010 Stuart Cochrane <stuartc1@gmail0.com>
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
if(isset($_REQUEST['Email_Address'])) {
include 'lite_settings.php';
if($email_to == 'youremailaddress@yourdomain.com') {
die('This message is for the Webmaster. Please enter your email address into the file "lite_settings.php"');
}
function died($error) {
echo 'Sorry, but there were error(s) found with the form you submitted. ';
echo 'These errors appear below.<br /><br />';
echo $error.'<br /><br />';
echo 'Please go back and fix these errors.<br /><br />';
die();
}
if(!isset($_REQUEST['Full_Name']) ||
!isset($_REQUEST['Email_Address']) ||
// !isset($_REQUEST['Telephone_Number']) || not required?
!isset($_REQUEST['Your_Message'])) {
died('We are sorry, but there appears to be a problem with the form you submitted.');
}
$full_name = $_REQUEST['Full_Name']; // required
$email_from = $_REQUEST['Email_Address']; // required
$telephone = $_REQUEST['Telephone_Number']; // not required
$comments = $_REQUEST['Your_Message']; // required
$error_message = '';
if(!preg_match('/^[[:alnum:]-_.]+@[[:alnum:]-_.]+\.[a-z]{2,4}$/i', $email_from)) {
$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
}
if(strlen($full_name) < 2) {
$error_message .= 'Your Name does not appear to be valid.<br />';
}
if(strlen($comments) < 2) {
$error_message .= 'The Comments you entered do not appear to be valid.<br />';
}
if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = 'Form details below.'."\r\n";
function clean_string($string) {
$bad = array('content-type', 'bc:', 'to:', 'cc:', 'href');
return str_replace($bad, '', $string);
}
$email_message .= 'Full Name: '.clean_string($full_name)."\r\n";
$email_message .= 'Email: '.clean_string($email_from)."\r\n";
$email_message .= 'Telephone: '.clean_string($telephone)."\r\n";
$email_message .= 'Message: '.clean_string($comments)."\r\n";
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@Mail($email_to, $email_subject, $email_message, $headers);
header('Location: '.$thankyou);
}
?>
[/highlight]

PS: fml, REQUEST should be POST, I cbf to send post values so I just used get
I just got phpwned.
Quote Originally Posted by Jason View Post


I just got phpwned.
Oh and if you thought this was wrong, it's not:

[highlight=php]
<html stuff here>
<? if(a) { ?>
<p>a is true</p>
<? } ?>
<p>is b true: <? if(b) { ?> yes <? } else { ?> no <? } ?>
<more html stuff here>
[/highlight]
Quote Originally Posted by Alen View Post
Oh and if you thought this was wrong, it's not:

[highlight=php]
<html stuff here>
<? if(a) { ?>
<p>a is true</p>
<? } ?>
<p>is b true: <? if(b) { ?> yes <? } else { ?> no <? } ?>
<more html stuff here>
[/highlight]
I know that works I had to do something similar for a ********* widget I made (though I didn't use the shorthand opening tags, 'cos ima baws).

I still have a LOOOOOOONG way to go with PHP.
Quote Originally Posted by Jason View Post
I know that works I had to do something similar for a ********* widget I made (though I didn't use the shorthand opening tags, 'cos ima baws).

I still have a LOOOOOOONG way to go with PHP.
Protip: never use short tags
Posts 1–9 of 9 · Page 1 of 1

Post a Reply

Tags for this Thread

None

Talk with us