所以我有兩個問題。我首先要知道的是有可能做的事情這樣...... 我有一個HTML頁面2種形式,它們是使用相同的PHP腳本..html表格處理php腳本
<?php
if ($conn) {
if (isset($_POST['form_student'])) {
if ($_POST['form_student'] == 'Send') {
if (isset($_POST['first_name']) && isset($_POST['last_name']) && isset($_POST['student_id']) && isset($_POST['gen'])) {
echo "<script>alert('Send information to the database.');</script>";
} else {
echo "<script>alert('You didn't fill in all fields!');</script>";
}
}
}
if (isset($_POST['form_subject'])) {
if ($_POST['form_subject'] == 'Send') {
if (isset($_POST['subject_id']) && isset($_POST['class_room']) && isset($_POST['day'])) {
echo "<script>alert('Send information to the database.');</script>";
} else {
echo "<script>alert('You didn't fill in all fields!');</script>";
}
}
}
}
?>
好了,所以第一個問題是關於,是有可能一些如何以這種方式來處理該動作腳本,並在html中顯示該警告框,而不會將我重定向到script.php,而不是將消息顯示給我。 第二個問題是,即使我沒有填寫所有字段,它總是迴應真實,而不是向我展示假的情況。
嘗試將每個字段的帖子值與「」進行比較。 isset是真實的,如果該字段存在的形式http://stackoverflow.com/questions/9986761/isset-function-is-returning-true-even-when-item-is-not-set-php-mysql –