diff --git a/dashboard.php b/dashboard.php new file mode 100644 index 0000000..f0f57d3 --- /dev/null +++ b/dashboard.php @@ -0,0 +1,47 @@ + + + + + + + Dashboard - My SaaS + + + + + + + +
+
+
+

Welcome, !

+

This is your dashboard. You are logged in.

+
+
+
+ + + + diff --git a/db/migrations/002_create_users_table.sql b/db/migrations/002_create_users_table.sql new file mode 100644 index 0000000..d5e7135 --- /dev/null +++ b/db/migrations/002_create_users_table.sql @@ -0,0 +1,7 @@ +CREATE TABLE IF NOT EXISTS `users` ( + `id` INT(11) UNSIGNED AUTO_INCREMENT PRIMARY KEY, + `username` VARCHAR(255) NOT NULL UNIQUE, + `email` VARCHAR(255) NOT NULL UNIQUE, + `password` VARCHAR(255) NOT NULL, + `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP +); diff --git a/index.php b/index.php index 1e55023..b9d8b37 100644 --- a/index.php +++ b/index.php @@ -179,6 +179,8 @@
  • Features
  • Testimonials
  • Contact
  • +
  • Login
  • +
  • Register
  • diff --git a/login.php b/login.php new file mode 100644 index 0000000..cb6b6ff --- /dev/null +++ b/login.php @@ -0,0 +1,108 @@ +prepare("SELECT * FROM users WHERE email = :email"); + $stmt->execute(['email' => $email]); + $user = $stmt->fetch(); + + if ($user && password_verify($password, $user['password'])) { + $_SESSION['user_id'] = $user['id']; + $_SESSION['username'] = $user['username']; + header("Location: dashboard.php"); + exit; + } else { + $error = 'Invalid email or password.'; + } + } catch (PDOException $e) { + $error = "Database error: " . $e->getMessage(); + } + } +} +?> + + + + + + Login - My SaaS + + + + + + + +
    +
    +
    +
    +
    +

    Login

    + + +
    Registration successful! Please log in.
    + + + +
    + + +
    +
    + + +
    +
    + + +
    +
    + +
    +
    +
    + +
    +
    +
    +
    + + + + diff --git a/logout.php b/logout.php new file mode 100644 index 0000000..766a593 --- /dev/null +++ b/logout.php @@ -0,0 +1,6 @@ +prepare("SELECT * FROM users WHERE username = :username OR email = :email"); + $stmt->execute(['username' => $username, 'email' => $email]); + if ($stmt->fetch()) { + $error = 'Username or email already exists.'; + } else { + // Insert new user + $hashed_password = password_hash($password, PASSWORD_DEFAULT); + $insert_stmt = $pdo->prepare("INSERT INTO users (username, email, password) VALUES (:username, :email, :password)"); + $insert_stmt->execute([ + 'username' => $username, + 'email' => $email, + 'password' => $hashed_password + ]); + + header("Location: login.php?registered=true"); + exit; + } + } catch (PDOException $e) { + $error = "Database error: " . $e->getMessage(); + } + } +} +?> + + + + + + Register - My SaaS + + + + + + + +
    +
    +
    +
    +
    +

    Create Account

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