Description: The checkUserData() function is used to verify the user's input data. This function checks user input data such as name, email, username, and password. If user input data is valid, then it returns true, otherwise, it returns an error message.
Code Examples:
Example 1:
function checkUserData($name, $email, $username, $password){
return "Password should be at least 6 characters long.";
}
}
else{
return "Username should contain only letters and numbers.";
}
}
else{
return "Invalid Email Address.";
}
}
else{
return "All fields are required.";
}
}
?>
In this code example, the checkUserData() function takes four parameters as input variables, which are name, email, username, and password. The function first checks if all input fields are not empty and then validates the email address using PHP's built-in FILTER_VALIDATE_EMAIL function. After that, the function checks if the username contains only letters and numbers using preg_match function. Finally, the function checks if the password is at least 6 characters long. If all the conditions are satisfied, the function returns true, otherwise, it returns an appropriate error message.
Package library: This function doesn't belong to any specific package library, but it is a part of the PHP language core library.
PHP User::checkUserData - 15 examples found. These are the top rated real world PHP examples of User::checkUserData extracted from open source projects. You can rate examples to help us improve the quality of examples.