我收到以下错误:
语法错误,第14行的C:\ xampp \ htdocs \ urd \ add_p_c.php中的意外T_IS_NOT_EQUAL
这是我的代码:
<?php
if(isset($_POST['submit'])){
#Email Msg Details
$emailSendTo = "myemail@email.com";
$emailSubj = "New Professor / Course Suggestion";
$_POST['name']= trim(strip_tags(addslashes($string)));
$_POST['deptName']= trim(strip_tags(addslashes($string)));
$_POST['email']= trim(strip_tags(addslashes($string)));
/* I can't remember if it should be '' or NULL, but some simple testing will let you know which it is*/
if($_POST['addType'] != NULL){
if($_POST['name'] != NULL){
if($_POST['deptName'] != NULL){
if($_POST['email']) != NULL){
$selected_radio = $_POST['addType'];
$course_prof_name = $_POST['name'];
$select_dep = $_POST['deptName'];
$email = $_POST['email'] = "myemail@email.com";
if(eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $emailSendTo)) {
return;
}
else {
echo "<span color='red;'>Invalid email address.</span>";
}
}
else{
echo "<span color='red;'>Oops need an email address.</span>";
}
}
else{
echo "<span color='red;'>Oops need a department.</span>";
}
}
else{
echo "<span color='red;'>Oops need a name.</span>";
}
}
else{
echo "<span color='red;'>Please select a radio option.</span>";
}
}
$email_message .= "Suggestion Type: ".clean_string($selected_radio)."\n";
$email_message .= "Suggestion Name: ".clean_string($course_prof_name)."\n";
$email_message .= "Department: ".clean_string($select_dep)."\n";
$email_message .= "Email: ".clean_string($email)."\n";
// create email headers
$headers = 'From: Anonymous User '."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($emailSendTo, $emailSubj, $email_message, $headers);
?>
以下是表单标记:
<form action='add_p_c.php' method='post'>
Professor<input type='radio' name='addType' /> Course<input type='radio' name='addType' />
<br><br>Name: <input type='text' name='name' /><br>
Department: <select name='deptName'><option>Department 1</option> <option>Department 2</option></select>
Email: <input type='text' name='email' /><br>
<input type='submit' name='submit' />
</form>
答案 0 :(得分:4)
if
声明之后你错过了一个右括号。
if(isset($_POST['submit'])){
^~~~ here.
答案 1 :(得分:0)
if语句后缺少右括号。
答案 2 :(得分:0)
第2行应
if(isset($_POST['submit'])){