我的索引页面顶部也有session_start();
,它无效!
<?php
if(isset($_REQUEST['Submit'])){
$key=substr($_SESSION['key'],0,5);
$captcha = $_REQUEST['captcha'];
if($captcha=!$key){
exit();
}
$EmailFrom = "****";
$EmailTo = "****";
$Subject = "****";
$contactname = Trim(stripslashes($_POST['contactname']));
$companyname = Trim(stripslashes($_POST['companyname']));
$username = Trim(stripslashes($_POST['username']));
$phone = Trim(stripslashes($_POST['phone']));
$email = Trim(stripslashes($_POST['email']));
// validation
$validationOK=true;
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=../404.php/\">";
exit;
}
// prepare email body text
$Body = "";
$Body .= "Contact Name: ";
$Body .= $contactname;
$Body .= "\n";
$Body .= "Company Name: ";
$Body .= $companyname;
$Body .= "\n";
$Body .= "Preferred Username: ";
$Body .= $username;
$Body .= "\n";
$Body .= "Phone: ";
$Body .= $phone;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $email;
$Body .= "\n";
// send email
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
// redirect to success page
if ($success){
print '<script type="text/javascript">';
print 'alert("Your Submission will be reviewed by an Admin and you will receive an email shortly")';
print '</script>';
print "<meta http-equiv=\"refresh\" content=\"0;URL=http://****.com/****/\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=../404.php/\">";
}
?>
答案 0 :(得分:2)
您最后错过}
(?>
之前)
请务必正确缩进代码以轻松捕获这些错误。
答案 1 :(得分:1)
在最后添加另一个花括号,我认为应该没问题
如果声明为if(isset($_REQUEST['Submit'])){
根据您的流程,您可以从
中删除花括号if($captcha=!$key){
exit();
这样就变成了
if($captcha!=$key)
exit();
请注意,我也将=!
更改为!=