以下の私のコードは、入力されていないフィールドがあるかどうかをチェックし、検証をチェックします。問題は、エラーがない場合でも最初のerror_messageを表示します。=
例えば
$error_message .= "<div class=\"error-header\">Error: You did not submit the following required information.</div>";
$error_message .= "<ul id=\"errors\">"
// this part in the second else statement always shows how do i stop that;
ここに完全なコード:
if((!$email_address)||(!$password)||(!$confirm_password)||(!$first_name)||(!$last_name)||(!$address)||(!$postal_code)||(!$region)||(!$country)) {
$error_message .= "<div class=\"error-header\">Error: You did not submit the following required information.</div>";
$error_message .= "<ul id=\"errors\">";
if(!$email_address) {
$error_message .= "<li>Please enter you're email address.</li>";
}
etc...
}else {
$error_message .= "<div class=\"error-header\">Error: The following information is invalid.</div>";
$error_message .= "<ul id=\"errors\">";
if($row_count > 0) {
$error_message .= "<li>The email address you provided is already in use, please use another email address.</li>";
}
if($confirm_password != $password) {
$error_message .= "<li>The passwords do not match.</li>";
}
if(!isset($_POST["interests"]) || count($_POST["interests"]) < 3) {
$error_message .= "<li>Please choose three departments that are of interest to you.</li>";
}else{
$interests = $_POST["interests"];
}
if(strtolower($captcha_code) == strtolower((string)$_SESSION["captcha"])) {
$error_message .= "<li>The code you entered is incorrect.</li>";
}
$error_message .= "</ul>";
}