2012-07-16 73 views
0

我有一個表格,我需要填寫一個字段。我正在嘗試但沒有取得任何成功。驗證表格php 4個輸入,必須填寫一個

請指出我在哪裏做錯了。

if($text1=='' && $text2=='' && ($text3!='' || $text4!='' || $text5!='' || $text6!='')){ 

        $abc->redirect('../xxxx.php'); 
        exit; 

        } 


<tr> 
<td>title: $</td> 
<td><input type="text" id="dailyprice" name="text1" style="height: 25px; border: 1px solid #888; width: 80px;"></td> 
<td>Desc: $</td> 
<td><input type="text" id="weeklyprice" name="text2" style="height: 25px; border: 1px solid #888; width: 80px;"></td> 
</tr> 

<tr> 
<td>Daily Price: $</td> 
<td><input type="text" id="dailyprice" name="text3" style="height: 25px; border: 1px solid #888; width: 80px;"></td> 
<td>Weekly Price: $</td> 
<td><input type="text" id="weeklyprice" name="text4" style="height: 25px; border: 1px solid #888; width: 80px;"></td> 
</tr> 
<tr> 
<td>Weekend Price: $</td> 
<td><input type="text" id="weekendprice" name="text5" style="height: 25px; border: 1px solid #888; width: 80px;"></td> 
<td>Monthly Price: $</td> 
<td><input type="text" id="monthlyprice" name="text6" style="height: 25px; border: 1px solid #888; width: 80px;"></td> 
</tr> 

感謝

+0

「不成功」不是問題 – zerkms 2012-07-16 22:41:01

+0

的解釋你是說只有一個字段需要填充或所有領域? – DrinkJavaCodeJava 2012-07-16 22:42:22

+0

text1或text2必須填寫OR(text3 text4 text5和text6)必須填寫 – 2012-07-16 22:43:52

回答

0

如果我理解正確,然後嘗試這樣的事情。

if ((empty($text1) && empty($text2)) || (empty($text3) && empty($text4) && empty($text5) && empty($text5)) { 
    $abc->redirect('../xxxx.php'); 
    exit(); 
} 
+0

謝謝兄弟。非常感謝 – 2012-07-16 23:08:54

0

試試這個

if(isset($text1)== True && isset($text2)== True)) || (isset($text3)==True xor isset($text4)=True xor isset($text5)==true xor isset($text6)==true) 
相關問題