//add this function on function.php or other give other file name you are including on php page
function checkRequiredPost($requiredField) {
$numRequired = count($requiredField);
$keys = array_keys($_POST);
$allFieldExist = true;
foreach($requiredField as $reqr)
{
if($_POST[trim($reqr)]==''){$allFieldExist=false;break;}
}
return $allFieldExist;
}
// use below code before insert/update query
$required=array('txt_name','txt_password'); // add fields name you want to mandatory them like name,password etc.
if(isset($_POST['submit']) && checkRequiredPost($required))
{
////type your code or insert/update query
}