diff --git a/assets/css/login.css b/assets/css/login.css new file mode 100644 index 0000000..96288fd --- /dev/null +++ b/assets/css/login.css @@ -0,0 +1,49 @@ +html, +body { + height: 100%; +} + +body { + display: -ms-flexbox; + display: -webkit-box; + display: flex; + -ms-flex-align: center; + -ms-flex-pack: center; + -webkit-box-align: center; + align-items: center; + -webkit-box-pack: center; + justify-content: center; + padding-top: 40px; + padding-bottom: 40px; + background-color: #f5f5f5; +} + +.form-signin { + width: 100%; + max-width: 330px; + padding: 15px; + margin: 0 auto; +} +.form-signin .checkbox { + font-weight: 400; +} +.form-signin .form-control { + position: relative; + box-sizing: border-box; + height: auto; + padding: 10px; + font-size: 16px; +} +.form-signin .form-control:focus { + z-index: 2; +} +.form-signin input[type="email"] { + margin-bottom: -1px; + border-bottom-right-radius: 0; + border-bottom-left-radius: 0; +} +.form-signin input[type="password"] { + margin-bottom: 10px; + border-top-left-radius: 0; + border-top-right-radius: 0; +} \ No newline at end of file diff --git a/assets/logo/dark.png b/assets/logo/dark.png new file mode 100644 index 0000000..ddf4e73 Binary files /dev/null and b/assets/logo/dark.png differ diff --git a/assets/logo/purple.png b/assets/logo/purple.png new file mode 100644 index 0000000..b49ad77 Binary files /dev/null and b/assets/logo/purple.png differ diff --git a/components/homepage/main.php b/components/homepage/main.php index 1dc1c3f..b71d25b 100644 --- a/components/homepage/main.php +++ b/components/homepage/main.php @@ -1,9 +1,10 @@
\ No newline at end of file diff --git a/components/login/main.php b/components/login/main.php new file mode 100644 index 0000000..ceab743 --- /dev/null +++ b/components/login/main.php @@ -0,0 +1,33 @@ +prepare("SELECT * FROM users WHERE email = :email"); + $query->bindParam(':email', $_POST['email']); + $query->execute(); + $user = $query->fetch(PDO::FETCH_ASSOC); + + if ($user && password_verify($_POST['password'], $user['password'])) { + $_SESSION['user_id'] = $user['id']; + $_SESSION['first_name'] = $user['first_name']; + $_SESSION['is_admin'] = $user['is_admin']; + header("Location: index.php"); + } else { + $errorMessage = "Invalid email or password."; + } +} + +?> + + +
+ +

Please sign in

+ ' . $errorMessage . '' : '' ?> + + + + +

Not registered ? Create an account here

+
+ diff --git a/components/navigate/main.php b/components/navigate/main.php index 95ba452..8dfb17e 100644 --- a/components/navigate/main.php +++ b/components/navigate/main.php @@ -1,5 +1,14 @@

Lignes de Métro

@@ -20,7 +29,6 @@ include 'services/stop_service.php'; diff --git a/components/navigate/stop_list.php b/components/navigate/stop_list.php index 36dac1d..0fa2a3c 100644 --- a/components/navigate/stop_list.php +++ b/components/navigate/stop_list.php @@ -1,6 +1,8 @@
@@ -17,12 +19,12 @@ - -
Ajouter
+ +
- \ No newline at end of file + diff --git a/components/register/main.php b/components/register/main.php new file mode 100644 index 0000000..6b128d7 --- /dev/null +++ b/components/register/main.php @@ -0,0 +1,50 @@ +prepare("SELECT * FROM users WHERE email = :email"); + $query->bindParam(':email', $_POST['email']); + $query->execute(); + $user = $query->fetch(PDO::FETCH_ASSOC); + + if ($user) { + $errorMessage = "Email already used."; + } + } + +} +?> + + + +
+ +

Create an account

+ ' . $errorMessage . '' : '' ?> + +
+
+ +
+
+ +
+
+ +
+
+
+ +
+
+ +
+
+ + +

Already an account ? Login here

+
+ \ No newline at end of file diff --git a/index.php b/index.php index d8b5254..30d9b68 100644 --- a/index.php +++ b/index.php @@ -1,4 +1,5 @@ \ No newline at end of file diff --git a/login.php b/login.php new file mode 100644 index 0000000..9c6cd3d --- /dev/null +++ b/login.php @@ -0,0 +1,4 @@ + \ No newline at end of file diff --git a/logout.php b/logout.php new file mode 100644 index 0000000..a027511 --- /dev/null +++ b/logout.php @@ -0,0 +1,7 @@ + diff --git a/register.php b/register.php new file mode 100644 index 0000000..b0bfa1e --- /dev/null +++ b/register.php @@ -0,0 +1,4 @@ + \ No newline at end of file diff --git a/services/db.php b/services/db.php new file mode 100644 index 0000000..6d6d18b --- /dev/null +++ b/services/db.php @@ -0,0 +1,22 @@ +exec("CREATE DATABASE IF NOT EXISTS subwaySchedule"); + $conn->exec("USE subwaySchedule"); + + $conn->exec("CREATE TABLE IF NOT EXISTS users ( + id INT AUTO_INCREMENT PRIMARY KEY, + firstName VARCHAR(50) NOT NULL, + lastName VARCHAR(50) NOT NULL, + email VARCHAR(100) NOT NULL UNIQUE, + password VARCHAR(255) NOT NULL, + is_admin BOOLEAN NOT NULL DEFAULT 0 + )"); + + + +} catch(PDOException $e) { + echo "Connection failed: " . $e->getMessage(); +} +?> diff --git a/services/stop_service.php b/services/stop_service.php index 8c04710..ba2e1f6 100644 --- a/services/stop_service.php +++ b/services/stop_service.php @@ -1,10 +1,5 @@ \ No newline at end of file diff --git a/structure/header.php b/structure/header.php index 2ee3716..85c391d 100644 --- a/structure/header.php +++ b/structure/header.php @@ -5,6 +5,10 @@ Subway schedules - + '; + } + ?> \ No newline at end of file diff --git a/structure/main.php b/structure/main.php index 5bf0463..d87d71b 100644 --- a/structure/main.php +++ b/structure/main.php @@ -1,5 +1,20 @@ - - +
diff --git a/structure/navbar.php b/structure/navbar.php index ffffef8..d219a8a 100644 --- a/structure/navbar.php +++ b/structure/navbar.php @@ -1,25 +1,35 @@ -
-
\ No newline at end of file + + + + '; +} +?> \ No newline at end of file