开发者

How to stop php empty field message to appear when page open

开发者 https://www.devze.com 2023-03-04 21:35 出处:网络
i am using this code to print empty filed error if(isset($_POST[\'submit\'])){ $oth开发者_如何转开发1inp= new CheckInputFieldsAll();

i am using this code to print empty filed error

 if(isset($_POST['submit'])){ 
$oth开发者_如何转开发1inp= new CheckInputFieldsAll(); 
$oth1inp->other1=$_POST['other']; 
echo $oth1inp->chkInputOtherOne(); 
}

this code is on page B, to print error when i submit page B.

But when i go from page A to B it prints the error. as the page opens error message shows while it should show when i submit page B.

This question also sets some context: how to stop my php page from continuing when field is empty


If I understand the problem correctly you need some way of identifying whether it's pageA or pageB POSTing data to pageB.

You could include a hidden form input in the forms of both pages and check for it in the $_POST array as you're checking for the submit variable at the moment.

Another way of doing it would be to change the name of the submit button so that in the form on pageA it's called "submitA" and from pageB it's called "submitB"

0

精彩评论

暂无评论...
验证码 换一张
取 消