From f27d1d7babcc9eb5297992a593537be2c3039014 Mon Sep 17 00:00:00 2001 From: Ruben Zafra Traver Date: Thu, 22 Dec 2022 10:23:49 +0100 Subject: [PATCH 1/5] Session and Server Variables --- server_variables.php | 9 +++++++++ session_variables.php | 13 +++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 server_variables.php create mode 100644 session_variables.php diff --git a/server_variables.php b/server_variables.php new file mode 100644 index 0000000..0eefb80 --- /dev/null +++ b/server_variables.php @@ -0,0 +1,9 @@ +"; + +print_r($_SERVER); + +echo ""; + +?> \ No newline at end of file diff --git a/session_variables.php b/session_variables.php new file mode 100644 index 0000000..2f541ac --- /dev/null +++ b/session_variables.php @@ -0,0 +1,13 @@ +"; +print_r($_SESSION); +echo ""; + +?> \ No newline at end of file From 5fbcd1474dd80b6ed5cab0e1d0576ee45dd7a1c1 Mon Sep 17 00:00:00 2001 From: Ruben Zafra Traver Date: Thu, 22 Dec 2022 12:50:20 +0100 Subject: [PATCH 2/5] Final Login Exercise Commit --- loginExercise/close_session.php | 10 ++++ loginExercise/index.php | 88 +++++++++++++++++++++++++++++++++ loginExercise/panel.php | 29 +++++++++++ loginExercise/validate.php | 20 ++++++++ 4 files changed, 147 insertions(+) create mode 100644 loginExercise/close_session.php create mode 100644 loginExercise/index.php create mode 100644 loginExercise/panel.php create mode 100644 loginExercise/validate.php diff --git a/loginExercise/close_session.php b/loginExercise/close_session.php new file mode 100644 index 0000000..2bca065 --- /dev/null +++ b/loginExercise/close_session.php @@ -0,0 +1,10 @@ + \ No newline at end of file diff --git a/loginExercise/index.php b/loginExercise/index.php new file mode 100644 index 0000000..dfbbd17 --- /dev/null +++ b/loginExercise/index.php @@ -0,0 +1,88 @@ + + + + + + + + + + + + + Password must be at least 8 characters and must contain at least one lower case letter, one upper case letter and one digit

'; + // } else { + // echo "The form has been submitted"; + // } + // } + ?> +
+ +

Log In

+ + + Logged out successfully.
"; + } + } + ?> + + Your Email or Password are incorrect."; + break; + case "userempty": + echo ""; + break; + case "passempty": + echo ""; + break; + case "bothempty": + echo ""; + break; + } + } + ?> + +
+
+ + +
+ +
+ + +
+ +
+ +
+
+ + + + \ No newline at end of file diff --git a/loginExercise/panel.php b/loginExercise/panel.php new file mode 100644 index 0000000..e1105aa --- /dev/null +++ b/loginExercise/panel.php @@ -0,0 +1,29 @@ + + + + + + + + + + + PRIVATE ZONE + + +
+ +

PRIVATE ZONE

+ Logout + +
+ + + \ No newline at end of file diff --git a/loginExercise/validate.php b/loginExercise/validate.php new file mode 100644 index 0000000..bf2b8b2 --- /dev/null +++ b/loginExercise/validate.php @@ -0,0 +1,20 @@ + \ No newline at end of file From 398d21ac3ced545ea0ec4803dde40fe9b9e2e9de Mon Sep 17 00:00:00 2001 From: Ruben Zafra Traver Date: Thu, 22 Dec 2022 12:56:34 +0100 Subject: [PATCH 3/5] Updated Readme --- README.md | 35 +++++++++++++---------------------- 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 654a6a1..e2d25e1 100644 --- a/README.md +++ b/README.md @@ -1,45 +1,36 @@ -`#php` `#server` `#master-in-software-development` +# PHP Server Environment 💻 -# PHP Server Environment +> In this project we learnt how to explore the content of the variable $_SERVER which is injected to the running script, in it we can find information about the server environment and the client as well as creating a simple login form that validates the inputs, throws alerts for different cases and that can logout successfully. +For this I used session_start() to maintain the variables as well as: unset($_SESSION), session_destroy() and session_write_close() to logout. -

- Version -

+I also used Bootstrap to create a simple and beautiful layout and desing. -> In this project you will learn how to explore the content of the variable $_SERVER which is injected to the running script, in it we can find information about the server environment and the client. - -## Index +## Index ☟ - [Requirements](#requirements) -- [Repository](#repository) - [Technologies used](#technologies-used) -- [Project delivery](#project-delivery) - [Resources](#resources) -## Requirements +## Requirements - Learn how to use the $_SERVER - Understand what a server-side language is and what it is used for +- Learn how to handle errors +- Learn how to use Sessions -## Repository - -First of all you must fork this project into your GitHub account. - -To create a fork on GitHub is as easy as clicking the “fork” button on the repository page. - -Fork on GitHub - -## Technologies used +## Technologies used \* PHP +\* XAMPP +\* Bootstrap -## Project delivery +## Project delivery ✅ To deliver this project you must send a Pull Request as explained in the Students Handbook. Remember that the PR title must be with the format - Solution: + NAME AND SURNAME or TEAM NAMES AND SURNAMES. - For example: "Solution: Josep Riera", "Solution: Josep Riera, Toni Suárez, Marta Vázquez" -## Resources +## Resources 👀 - [$_SERVER](https://www.php.net/manual/en/reserved.variables.server.php) - [PHP.ini](https://www.php.net/manual/es/configuration.file.php) From c6fd872fee37ee7ea9eec6ceb956c8808a1fd30d Mon Sep 17 00:00:00 2001 From: Ruben Zafra Traver Date: Thu, 22 Dec 2022 12:57:10 +0100 Subject: [PATCH 4/5] Updated Readme Final --- README.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/README.md b/README.md index e2d25e1..5bd80cf 100644 --- a/README.md +++ b/README.md @@ -24,12 +24,6 @@ I also used Bootstrap to create a simple and beautiful layout and desing. \* XAMPP \* Bootstrap -## Project delivery ✅ - -To deliver this project you must send a Pull Request as explained in the Students Handbook. Remember that the PR title must be with the format -- Solution: + NAME AND SURNAME or TEAM NAMES AND SURNAMES. -- For example: "Solution: Josep Riera", "Solution: Josep Riera, Toni Suárez, Marta Vázquez" - ## Resources 👀 - [$_SERVER](https://www.php.net/manual/en/reserved.variables.server.php) From 6837a7cce5a358ca3f8880ab05f48fce343fdcf1 Mon Sep 17 00:00:00 2001 From: Ruben Zafra Traver Date: Fri, 23 Dec 2022 09:49:14 +0100 Subject: [PATCH 5/5] Refactor without echo --- loginExercise/index.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/loginExercise/index.php b/loginExercise/index.php index dfbbd17..7312570 100644 --- a/loginExercise/index.php +++ b/loginExercise/index.php @@ -51,17 +51,22 @@ Your Email or Password are incorrect."; + case "incorrect": + ?> + + Your Email is empty."; + ?> + Your Password is empty."; + ?> + Both inputs are empty."; + ?> +