PHP
<?php
if(isset($_POST['submit'])){
#Email Msg Details
$emailSendTo = "myemail@email.com";
$emailSubj = "New Professor / Course Suggestion";
$selected_radio = $_POST['addType'];
$course_prof_name = $_POST['name']= trim(strip_tags(addslashes($_POST['name'])));
$select_dep = $_POST['deptName']= trim(strip_tags(addslashes($_POST['deptName'])));
$email = $_POST['email']= trim(strip_tags(addslashes($_POST['email'])));
/* 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'];
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: ".$selected_radio."\n";
$email_message .= "Suggestion Name: ".$course_prof_name."\n";
$email_message .= "Department: ".$select_dep."\n";
$email_message .= "Email: ".$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);
?>
是什么 注意:未定义的索引:第13行的C:\ xampp \ htdocs \ urd \ add_p_c.php中的addType 请选择一个无线电选项。 注意:未定义的变量:第41行的C:\ xampp \ htdocs \ urd \ add_p_c.php中的email_message
注意:未定义的变量:第48行的C:\ xampp \ htdocs \ urd \ add_p_c.php中的email_from
意思?
答案 0 :(得分:0)
您的作业是正确的,但不存在变量$string
(您在第6,7行中引用等等)。这就是为什么它抱怨未定义的变量string。
对于第11行,你想要:
if(isset($_POST['var']))
对于未定义的方法,您尚未定义该方法(或至少可以从第39行调用的位置)。
答案 1 :(得分:0)
看来$ string未定义。
答案 2 :(得分:0)
我在任何地方都没有看到$ string的定义。
答案 3 :(得分:0)
@ user700070:更改
$course_prof_name = $_POST['name']= trim(strip_tags(addslashes($string)));
$select_dep = $_POST['deptName']= trim(strip_tags(addslashes($string)));
$email = $_POST['email']= trim(strip_tags(addslashes($string)));
到
$course_prof_name = $_POST['name'];
$select_dep = $_POST['deptName'];
$email = $_POST['email'];
您的HTML(我在您编辑帖子并删除之前看到的示例)也应该从
Professor<input type='radio' name='addType' /> Course<input type='radio' name='addType' />
到
Professor<input type="radio" name="addType" value="Professor" /> Course<input type="radio" name="addType" value="Course" />
否则addType
将始终为空。