Home > Enterprise >  how to check if any of the three form value submitted?
how to check if any of the three form value submitted?

Time:10-18

If there are multiple input fields in a from, is there a way to check if atleast one has data ?

for example $_POST["data1"] and $_POST["data2"] and $_POST["data1"]

if atleast one of the above has data is should be valid. if none has data invalid

if (any three post has data) { echo "valid"; } else { echo "invalid"; }

the following can be used to check if an input form or a checkbox submitted data. but I want to add two more data sources ($_POST["data2"] and $_POST["data1"]) if(!empty($_POST["data1"])) { #some code }

How ?

CodePudding user response:

you can give this input value defualt value like

        <input name = "data1" value ="null"> 

and check if the $_POST["data1"] === "null" then do some code

  •  Tags:  
  • php
  • Related