6. Using HTTP
Activity 6.1: Creating a Support Contact Form
Solution
- The first thing that pops out is the login handling difference since we now have to authenticate random users, not just a single one. So, we will need a method to fetch the user data for the username that is being logged in. The method will return user data for the existing user (using the
level
andpassword
hashes), orNULL
if the user is not found. Since we will learn about databases in the next chapter, we will store the available user list in code, in the same way as the previous exercise:Login.php
37Â private function getUserData(string $username): ?array 38Â { 39Â Â Â Â Â $users = [ 40Â Â Â Â Â Â Â Â Â 'vip' => [ 41Â Â Â Â Â Â Â Â Â Â Â Â Â 'level' => 'VIP', 42Â Â Â Â Â Â Â Â Â Â Â Â Â 'password...