I want to check a input value with preg_match. So if user insert anything on input field, preg_match check this value else return error. But if have no input value, sql save only empty field.
When I insert anything on input field, preg_match working well but if input value is empty this preg_match stop insert anything on sql.
here is this:
$langu = mysqli_real_escape_string($db, $_POST['langu']);
$relig = mysqli_real_escape_string($db, $_POST['relig']);
if(preg_match("/^([0-9a-zA-Z])+$/i", $langu) || preg_match("/^([0-9a-zA-Z])+$/i", $relig)){
// insert at sql
// If $langu or $relig is empty store empty, but I cannot parsing empty value by preg_match
} else { echo 'error';}