diff --git a/assets/css/custom.css b/assets/css/custom.css index 6c1d8cd..372e9b7 100644 --- a/assets/css/custom.css +++ b/assets/css/custom.css @@ -160,3 +160,92 @@ body { background-color: #dc3545; border-color: #dc3545; } + +/* Login Page Styles */ +.login-container { + display: flex; + justify-content: center; + align-items: center; + min-height: 80vh; + padding: 2rem; +} + +.login-form { + background-color: #ffffff; + padding: 2.5rem; + border-radius: 0.5rem; + box-shadow: 0 4px 12px rgba(0,0,0,0.1); + width: 100%; + max-width: 400px; +} + +.login-form h2 { + text-align: center; + margin-bottom: 1.5rem; + color: #333; +} + +.login-form .form-group { + margin-bottom: 1.5rem; +} + +.login-form label { + display: block; + margin-bottom: 0.5rem; + color: #555; + font-weight: 500; +} + +.login-form input[type="email"], +.login-form input[type="password"] { + width: 100%; + padding: 0.75rem; + border: 1px solid #ccc; + border-radius: 0.25rem; + transition: border-color 0.2s; +} + +.login-form input[type="email"]:focus, +.login-form input[type="password"]:focus { + outline: none; + border-color: #007bff; +} + +.login-form .btn-submit { + width: 100%; + padding: 0.75rem; + background-color: #007bff; + color: white; + border: none; + border-radius: 0.25rem; + font-size: 1rem; + cursor: pointer; + transition: background-color 0.2s; +} + +.login-form .btn-submit:hover { + background-color: #0056b3; +} + +.login-form .errors { + background-color: #f8d7da; + color: #721c24; + padding: 1rem; + border: 1px solid #f5c6cb; + border-radius: 0.25rem; + margin-bottom: 1.5rem; +} + +.login-form .register-link { + text-align: center; + margin-top: 1.5rem; +} + +.login-form .register-link a { + color: #007bff; + text-decoration: none; +} + +.login-form .register-link a:hover { + text-decoration: underline; +} diff --git a/db/migrate.php b/db/migrate.php new file mode 100644 index 0000000..79220a0 --- /dev/null +++ b/db/migrate.php @@ -0,0 +1,26 @@ +exec($sql); + echo "Executed migration: " . basename($migration) . "
"; + } + } + + echo "All migrations executed successfully.
"; + +} catch (PDOException $e) { + header('HTTP/1.1 500 Internal Server Error'); + die("Database migration failed: " . $e->getMessage()); +} diff --git a/db/migrations/001_create_users_table.sql b/db/migrations/001_create_users_table.sql new file mode 100644 index 0000000..53c0e35 --- /dev/null +++ b/db/migrations/001_create_users_table.sql @@ -0,0 +1,9 @@ +CREATE TABLE IF NOT EXISTS `users` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `email` varchar(255) NOT NULL, + `password` varchar(255) NOT NULL, + `google_id` varchar(255) DEFAULT NULL, + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`), + UNIQUE KEY `email` (`email`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; diff --git a/footer.php b/footer.php new file mode 100644 index 0000000..99a45a9 --- /dev/null +++ b/footer.php @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/header.php b/header.php new file mode 100644 index 0000000..c9e1d14 --- /dev/null +++ b/header.php @@ -0,0 +1,10 @@ + + + + + + My App + + + +
\ No newline at end of file diff --git a/index.php b/index.php index 7787781..edb8728 100644 --- a/index.php +++ b/index.php @@ -1,3 +1,11 @@ + @@ -22,6 +30,7 @@

Welcome to Your AI-Powered Assistant

Ask questions, generate images, and interact with voice commands.

Get Started + Logout
@@ -79,4 +88,4 @@ - \ No newline at end of file + diff --git a/login.php b/login.php new file mode 100644 index 0000000..6df751a --- /dev/null +++ b/login.php @@ -0,0 +1,78 @@ +prepare("SELECT id, password FROM users WHERE email = ?"); + $stmt->execute([$email]); + $user = $stmt->fetch(); + + if ($user && password_verify($password, $user['password'])) { + $_SESSION['user_id'] = $user['id']; + header('Location: index.php'); + exit; + } else { + $errors[] = 'Invalid email or password.'; + } + } catch (PDOException $e) { + $errors[] = 'Database error: ' . $e->getMessage(); + } + } +} + +include 'header.php'; +?> + +
+
+

Login

+ + +
+ +

+ +
+ + +
+
+ + +
+
+ + +
+ +
+ + +
+
+ + diff --git a/logout.php b/logout.php new file mode 100644 index 0000000..2c78059 --- /dev/null +++ b/logout.php @@ -0,0 +1,7 @@ + diff --git a/register.php b/register.php new file mode 100644 index 0000000..f1cff81 --- /dev/null +++ b/register.php @@ -0,0 +1,77 @@ +prepare("SELECT id FROM users WHERE email = ?"); + $stmt->execute([$email]); + if ($stmt->fetch()) { + $errors[] = 'Email already exists.'; + } else { + $hashed_password = password_hash($password, PASSWORD_DEFAULT); + + $stmt = $pdo->prepare("INSERT INTO users (email, password) VALUES (?, ?)"); + $stmt->execute([$email, $hashed_password]); + + $success = 'Registration successful! You can now login.'; + } + } catch (PDOException $e) { + $errors[] = 'Database error: ' . $e->getMessage(); + } + } +} + +include 'header.php'; +?> + +

Register

+ + +
+ +

+ +
+ + + +
+

+
+ +
+
+ + +
+
+ + +
+ +
+ + +

Already have an account? Login here.

+ +