Create a login page (username and password) that checks the credentials against the database.
We will now integrate what we have done into a consistent application. First, create a menu containing:
You will reuse the TV shows list, the registration and the login implemented previously
Make sure the menu is shared between the pages. To do this, you can use for example the include function to put the menu code in a separate file.
When the user is logged in, display a different menu:
Where toto@toto.com is the email address of the logged-in user.
The logout link must log the user out and send them back to the home page.
Using the user_series table in the database, make it possible for a user
to "follow" a show (which will then be associated with them) or to stop following a show.
This feature will only appear when the user is logged in
When they visit the show's page, they will see whether they follow it or not.
Create a page listing the shows followed by the user. This page will also appear in the menu, only when the user is logged in.
By adding JavaScript code, in particular the fetch function, make it possible for the user to follow or stop following a show without reloading the page.
The goal of this exercise is to implement a CAPTCHA, a visual code that the user must copy to confirm they are not a robot when they sign up, using the registration you implemented in the previous part.
The code that generates the image is already provided in the captcha.zip archive.
1. Setup
Add a field to your registration form, with a text input, and display
the image generated by captcha.php, asking the user to copy it in order to
confirm they are not a robot.
2. Random phrases
Make the code displayed in the image randomly generated.
3. Validation
Now write the code that checks whether the user correctly copied the displayed code.
Warning: When the form is submitted, you must check on the server side that the code entered by the user is indeed the one previously displayed on their image. Obviously, you must avoid sending the code in plain text to the user!
Do the same as the previous exercise, but implement the session
system yourself (without using session_start() or
$_SESSION)
A few useful functions:
// Read and write a file
file_put_contents($file, $data); // Write
$data = file_get_contents($file); // Read
// Test whether a file $file exists
if (file_exists($file)) {
}
// Generate a random id
$id = uniqid();
// Turn an object into a string
$data = serialize($something);
// Turn a string into an object
$something = unserialize($data);
// Set a cookie 'key' to '123' that will expire when the
// browser is closed
setcookie('key', '123', 0);