0
我也有session_start();
在我的索引頁面的頂部,它不工作!我簡單的驗證碼php腳本有什麼問題?
<?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/\">";
}
?>
什麼是錯誤,dawg? – metaforce 2011-05-31 10:02:39
這只是應該認識到由captcha字段生成的字符串,並驗證它,但我的PHP有點弱:/ – iamwhitebox 2011-05-31 10:02:42
解析錯誤:語法錯誤,意想不到的$在行結束56 **** – iamwhitebox 2011-05-31 10:03:11