Har*_*M V -1 php forms validation
我有一个PHP表单,我需要提交4个字段数据.
现在我必须检查以上所有数据是否可用.
出于调试目的,我在下面使用$ _GET
if (!empty($_GET['name']) or !empty($_GET['email']) or !empty($_GET['password']) or !empty($_GET['mobile'])) {
$response = array(
'status' => 'OK',
'error' => '1',
'message' => 'Registered successfully. Please check your email for activation details',
'data' => '');
} else {
$response = array(
'status' => 'NOK',
'error' => '1',
'message' => 'There was some error please try again.',
'data' => '');
}
Run Code Online (Sandbox Code Playgroud)
以上内容无法正确验证表单.
and在条件下使用很重要,而不是or:
if (!empty($_GET['name']) and !empty($_GET['email']) and !empty($_GET['password']) and !empty($_GET['mobile'])) {
Run Code Online (Sandbox Code Playgroud)