How can the "define" function be used to set up user authentication in PHP?
User authentication in PHP can be set up using the "define" function to define constants for usernames and passwords. These constants can then be used to compare the user input with the predefined values to authenticate users.
define('USERNAME', 'admin');
define('PASSWORD', 'password');
$user = $_POST['username'];
$pass = $_POST['password'];
if($user == USERNAME && $pass == PASSWORD){
// User is authenticated
echo "Welcome, ".$user."!";
} else {
// Authentication failed
echo "Invalid username or password.";
}