-1
嗨即時貼發佈一個textarea值的頁面和值必須等於「2011」如果它不想我要拋出一個錯誤。不能添加if語句php
我輸入
<fieldset>
<span class="subtitle">What year is it?</span>
<input type="text" name="aspam" id="aspam"/>
</fieldset>
和我的PHP是
if(!isset($_POST['produgg_username']) or !isset($_POST['produgg_password']) or !isset($_POST['produgg_email']) or $_POST['aspam'] != '2011')
{
print "Please use all fields";
}elseif(empty($_POST['produgg_username'])){
print "Please choose a username";
}elseif($_POST['aspam'] != '2011'){
print "its not 2011!";
}elseif(empty($_POST['produgg_password'])){
print "Please choose a password";
}elseif(empty($_POST['produgg_email'])){
print "Please enter an email address";
}elseif(!filter_var($_POST['produgg_email'], FILTER_VALIDATE_EMAIL)) {
print "Please enter a valid email address";
}elseif(!preg_match("/^[a-z0-9]+$/i", $_POST['produgg_username'])) {
print "Please use only characters and numbers for username";
}elseif($usersClass->checkUserExists($_POST['produgg_username'])) {
print "Username Taken, please choose another";
問題是......? – KingCrunch
你錯過了一個右大括號 – JoshB
我只是喜歡做順序驗證的表單。輸入一個字段,提交,得到一個錯誤,修復字段,提交,得到另一個錯誤...所以用戶友好! –