我已经做了这样的事情:使用或(||)在PHP如果条件产生问题
<form action="validate.php" method="get">
Id :<input type="text" name="pID"/><br/><br/>
Name :<input type="text" name="pName"/><br/><br/>
Description :<input type="text" name="pDesc"/><br/><br/>
Price :<input type="text" name="pPrice"/><br/><br/>
<input type="submit" name="pSub"/>
</form>
我validate.php包括:工作不正常
<?php
if (!empty($_GET['pID']) || !empty($_GET['pName']) || !empty($_GET['pDesc']) || !empty($_GET['pPrice'])){
if(is_numeric($_GET['pID']) || is_numeric($_GET['pPrice']))
{
echo "</br>Your ID :".$_GET["pID"]."</br>";
echo "Name is :".$_GET["pName"]."</br>";
echo "Description :".$_GET["pDesc"]."</br>";
echo "and Price :".$_GET["pPrice"]."</br>";
}
else{echo "Pls See That ID and Price are Numerical";}
}else{
echo "Fill up All The Values";
}
?>
,
如果条件无法正常工作,则为第一个 即。如果我留下空白的“名称”输入字段消息应该有所说 “填满所有的值”......而不是它显示输入列表
是否有任何其他方式来验证窗体(PHP)
好点:这种形式更具可读性。 – Piskvor 2010-03-10 09:19:37