我正在研究PHP類的最終項目,我在驗證代碼時遇到了問題。在其他部分代碼中,如果語句和應用程序停止處理,我總是會在這兩處發生錯誤。 下面的代碼是.php文件的一部分,它具有用於設置提醒的HTML表單。PHP驗證問題
} else if (!checkdate($_POST['reminderMonth'],$_POST['reminderDate'],$_POST['remindereEar'])) {
$error_message = "Selected date does not exist.";
} else if ($reminderDate <= $t_date) {
$error_message = "Selected date has already occured.";
所有代碼:
if(isset($_POST['submit'])) {
//get data
$t_date = date(Ymd);
$year = $_POST['reminderYear'];
$month = $_POST['reminderMonth'];
$day = $_POST['reminderDay'];
//validate data
$reminderDate = $year.$month.$day;
if (empty($_POST['reminderName'])) {
$error_message = "Name is a required field.";
} else if (!checkdate($_POST['reminderMonth'],$_POST['reminderDate'],$_POST['remindereEar'])) {
$error_message = "Selected date does not exist.";
} else if ($reminderDate <= $t_date) {
$error_message = "Selected date has already occured.";
} else {
$error_message = ''; }
//redirect
if(empty($error_message)) {
mysql_query("INSERT INTO reminder_event
(reminderName,reminderDescript,reminderDate)
VALUES
('{$reminderName}','{$reminderDescript}','{$reminderDate}')");
header("Refresh: 1;url=reminder_list.php");
} else {
echo($error_message); } }
什麼錯誤? –
對不起,我錯過了......厭倦了所有的考試費用。 – cmorris1441