Topic: Error message
Tried to implement an anti-spam captcha code on modified contact form found here :
Contact Form 1.0.0
But i have an error :
Parse error: parse error, unexpected $ in /forum/contact.php on line 125
Here is my contact.php :
<?php
define('PUN_ROOT', './');
define('PUN_QUIET_VISIT', 1);
require PUN_ROOT.'include/common.php';
$page_title = pun_htmlspecialchars($pun_config['o_board_title']) . ' / Contact'; //Set the page title here
define('PUN_ALLOW_INDEX', 1);
require PUN_ROOT.'header.php';
require PUN_ROOT.'include/parser.php';
//echo "<PRE>"; print_r ($pun_config); echo "</PRE>";
if ($_POST[form_sent] == 1) {
//Process The Form
?>
<?php
$as = $_POST['antispam'];
$as2 = $_POST['spamvalidator'];
if ($as != $as2){
?>
<div class="blockform">
<h2><span>Contact <?php echo $pun_config['o_board_title']; ?></span></h2>
<div class="box">
<form id="contact" method="post" action="contact.php">
<div class="inform">
<fieldset>
<legend>Email not sent</legend>
<div class="infldset">
<b>Your mail could not be sent!</b> The antispamcode you entered did not match.
</div>
</fieldset>
</div>
</form>
</div>
</div>
<?php
}elseif($as == $as2){
$recipient = "$toName <".$toMail.">";
$headers ="From: ".$_POST[name]." <".$_POST[email].">";
$subject = "WEBFORM:".$_POST[subject];
$message = str_replace("\\", "", $_POST[comments]);
mail($pun_config['o_admin_email'], $subject, $message, $headers);
?>
<div class="blockform">
<h2><span>Contact <?php echo $pun_config['o_board_title']; ?></span></h2>
<div class="box">
<form id="contact" method="post" action="contact.php">
<div class="inform">
<fieldset>
<legend>Email Sent</legend>
<div class="infldset">
<b>Thank you for contacting us!</b> The following information was sent to <?php echo $pun_config['o_board_title']; ?>.<br /><br />
<label>Name:<br /><?php echo $_POST[name]; ?><br /></label>
<label>Email:<br /><?php echo $_POST[email]; ?><br /></label>
<label>Subject:<br /><?php echo $_POST[subject]; ?><br /></label>
<label>Comments:<br /><?php echo $_POST[comments]; ?><br /></label>
</div>
</fieldset>
</div>
</form>
</div>
</div>
<?php } else {
//Display the Form
$antispam = dechex(rand(hexdec(000000), hexdec(FFFFFF)));
?>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_validateForm() { //v4.0
var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
if (val) { nm=val.name; if ((val=val.value)!="") {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p<1 || p==(val.length-1)) errors+='- '+nm+' must be an e-mail address.\n';
} else if (test!='R') { num = parseFloat(val);
if (isNaN(val)) errors+='- '+nm+' must be a number.\n';
if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (num<min || max<num) errors+='- '+nm+' must be a number between '+min+' and '+max+'.\n';
} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
} if (errors) alert('The following errors occurred:\n'+errors);
document.MM_returnValue = (errors == '');
}
//-->
</script>
<div class="blockform">
<h2><span>Contact <?php echo $pun_config['o_board_title']; ?></span></h2>
<div class="box">
<form id="contact" method="post" action="contact.php">
<div class="inform">
<fieldset>
<legend>Enter your contact details</legend>
<div class="infldset">
Please enter your contact information and comments here. If you would like to share your comments with everyone, consider posting them on the <a href="forum.php">forum</a> instead!<br />
<input type="hidden" name="form_sent" value="1" /><br />
<label>Name<br /><input type="text" name="name" value="" size="40" maxlength="40" /><br /></label>
<label>Email<br /><input type="text" name="email" value="" size="40" maxlength="50" /><br /></label>
<label>Subject<br /><input type="text" name="subject" value="" size="40" maxlength="50" /><br /></label>
<label>Comments<br /><textarea name="comments" rows="5" cols="40"></textarea><br /></label>
<label>No spam:<br /><input name="antispam" type="text" class="tekst" size="6"> <?php echo $antispam; ?> <input type="hidden" value="<?php echo $antispam; ?>" name="spamvalidator" /></label>
</div>
</fieldset>
</div>
<p><input type="submit" name="update" value="Submit" onClick="MM_validateForm('name','','R','email','','RisEmail','subject','','R');return document.MM_returnValue" /></p>
</form>
</div>
</div>
<?php
} //close if statement
require PUN_ROOT.'footer.php';
Any advice ?
Regards