我想讓我的PHP驗證用戶已經放入需要的信息。PHP郵件空白變量
我想確保這個人已經把名字和電子郵件。當我把:
if(empty($name){
blah blah
}
它給出的錯誤,但它仍然處理電子郵件。當我把:
if(empty($name){
blah blah
}else{
blah blah
}
我收到一個錯誤說:Parse error: syntax error, unexpected '}' in /home/dreamcpu/public_html/insert.php on line 34
。
這裏是我的PHP:
<?php
$con = mysql_connect("localhost","blah","blah");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
$today = date("F j, Y, g:i a");
mysql_select_db("dreamcpu_contact_info", $con);
$sql="INSERT INTO contact_us (name, email,phone_number,job_request,DateRequested)
VALUES
('$_POST[name]','$_POST[email]','$_POST[phone_number]','$_POST[job_requested]','$today')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error(). "Actual query: " . $sql);
}
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone_number'];
$job = $_POST['job_requested'];
if (empty($name)){
echo "The name field was blank. Please go back and fill in the required fields";
}
else
{
$to = "[email protected]";
$subject = "A job have been requested";
$message = "On " . $today . " a job has been requested from " . $name . " please email them at " . $email . " or call them at " . $phone;
$headers = "From:" . $email;
mail($to, $subject, $message,$headers);
echo "<h3 style='display:block;'>Thank you for contacting DreamCPU. We have received your request $_POST[name]. We will review it and contact you as soon as possible.</h3>";
mysql_close($con)
}
?>
非常基本的PHP運行時錯誤。我建議使用帶有行號的編輯器和關於基本語法的php手冊。 – tuergeist 2011-12-20 21:42:46
事情沒有了;當我正在處理sql連接 – 2011-12-21 19:09:52
爲什麼這個問題downvoted? – 2011-12-21 19:21:55