所以我有两个问题。我想首先知道是否有可能以这种方式做事......我有一个 html 页面,其中包含 2 个使用相同 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,而不是向我显示消息。第二个问题是,即使我没有填写所有字段,它总是呼应真实,而不是向我展示虚假案例。