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...