<?php // function function check($input){ $check = TRUE; foreach($input as $value){ if($value == ""){ $check = FALSE; } } return $check; } if($_SERVER['REQUEST_METHOD'] == 'POST'){ $input =array( $_POST['txtUsername'], $_POST['txtFirstname'], $_POST['txtLastname'] ); // เรียกใช้งาน if(check($input) == TRUE){ echo 'Success!'; }else{ echo 'Fail'; } } ?> <!--Form--> <form action="test.php" method="post" name="test"> <input type="text" value="" name="txtUsername"> <br/> <input type="text" value="" name="txtFirstname"> <br/> <input type="text" value="" name="txtLastname"> <br/> <input type="submit" value="Check"> </form>