diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c2658d7 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules/ diff --git a/classes/Login.php b/classes/Login.php index 7df819f..6a3d7df 100644 --- a/classes/Login.php +++ b/classes/Login.php @@ -107,7 +107,7 @@ public function doLogout() // delete the session of the user $_SESSION = array(); session_destroy(); - // return a little feeedback message + // return a little feedback message $this->messages[] = "You have been logged out."; } diff --git a/index.php b/index.php index c564760..867bd32 100644 --- a/index.php +++ b/index.php @@ -29,6 +29,9 @@ // so this single line handles the entire login process. in consequence, you can simply ... $login = new Login(); +// include header with Bootstrap +include("views/header.php"); + // ... ask if we are logged in here: if ($login->isUserLoggedIn() == true) { // the user is logged in. you can do whatever you want here. @@ -40,3 +43,6 @@ // for demonstration purposes, we simply show the "you are not logged in" view. include("views/not_logged_in.php"); } + +// include footer +include("views/footer.php"); diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..fee5f68 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,42 @@ +{ + "name": "php-login-minimal", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "dependencies": { + "bootstrap": "^5.3.8" + } + }, + "node_modules/@popperjs/core": { + "version": "2.11.8", + "resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.11.8.tgz", + "integrity": "sha512-P1st0aksCrn9sGZhp8GMYwBnQsbvAWsZAX44oXNNvLHGqAOcoVxmjZiohstwQ7SqKnbR47akdNi+uleWD8+g6A==", + "license": "MIT", + "peer": true, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/popperjs" + } + }, + "node_modules/bootstrap": { + "version": "5.3.8", + "resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-5.3.8.tgz", + "integrity": "sha512-HP1SZDqaLDPwsNiqRqi5NcP0SSXciX2s9E+RyqJIIqGo+vJeN5AJVM98CXmW/Wux0nQ5L7jeWUdplCEf0Ee+tg==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/twbs" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/bootstrap" + } + ], + "license": "MIT", + "peerDependencies": { + "@popperjs/core": "^2.11.8" + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..719e5df --- /dev/null +++ b/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "bootstrap": "^5.3.8" + } +} diff --git a/register.php b/register.php index e185126..faaf151 100644 --- a/register.php +++ b/register.php @@ -29,5 +29,11 @@ // so this single line handles the entire registration process. $registration = new Registration(); +// include header with Bootstrap +include("views/header.php"); + // show the register view (with the registration form, and messages/errors) include("views/register.php"); + +// include footer +include("views/footer.php"); diff --git a/views/footer.php b/views/footer.php new file mode 100644 index 0000000..5bea677 --- /dev/null +++ b/views/footer.php @@ -0,0 +1,6 @@ + + + + + + diff --git a/views/header.php b/views/header.php new file mode 100644 index 0000000..277a209 --- /dev/null +++ b/views/header.php @@ -0,0 +1,30 @@ + + + + + + PHP Login System + + + + + + +
+ diff --git a/views/logged_in.php b/views/logged_in.php index 63af4f2..2de11bf 100644 --- a/views/logged_in.php +++ b/views/logged_in.php @@ -1,6 +1,12 @@ -Hey, . You are logged in. -Try to close this browser tab and open it again. Still logged in! ;) + -Logout +
+ Logout +
diff --git a/views/not_logged_in.php b/views/not_logged_in.php index d433d25..5c3c8eb 100644 --- a/views/not_logged_in.php +++ b/views/not_logged_in.php @@ -3,28 +3,34 @@ if (isset($login)) { if ($login->errors) { foreach ($login->errors as $error) { - echo $error; + echo ''; } } if ($login->messages) { foreach ($login->messages as $message) { - echo $message; + echo ''; } } } ?> -
+ - - +
+ + +
- - +
+ + +
- +
-Register new account +
+ Register new account +
diff --git a/views/register.php b/views/register.php index 594c6f2..4377c8b 100644 --- a/views/register.php +++ b/views/register.php @@ -3,36 +3,47 @@ if (isset($registration)) { if ($registration->errors) { foreach ($registration->errors as $error) { - echo $error; + echo ''; } } if ($registration->messages) { foreach ($registration->messages as $message) { - echo $message; + echo ''; } } } ?> -
+ - - +
+ + +
- - +
+ + +
- - +
+ + +
- - - +
+ + +
+ +
-Back to Login Page +
+ Back to Login Page +