diff --git a/dashboard.php b/dashboard.php new file mode 100644 index 0000000..52d4c05 --- /dev/null +++ b/dashboard.php @@ -0,0 +1,42 @@ + + +
+
+

Dashboard

+ Logout +
+ +
+
+

Welcome, !

+

You are logged in as .

+ + Administrator + +
+
+ +
+
+

AI App Generator

+
+
+

This is where the AI-powered application generator will be.
You'll be able to describe your app idea and see it come to life!

+ +
+
+ +
+ + diff --git a/database.sql b/database.sql new file mode 100644 index 0000000..e9ba5e6 --- /dev/null +++ b/database.sql @@ -0,0 +1,32 @@ +-- +-- Database: `app_30908` +-- + +-- -------------------------------------------------------- + +-- +-- Table structure for table `contact_submissions` +-- + +CREATE TABLE IF NOT EXISTS `contact_submissions` ( + `id` INT AUTO_INCREMENT PRIMARY KEY, + `name` VARCHAR(255) NOT NULL, + `email` VARCHAR(255) NOT NULL, + `message` TEXT NOT NULL, + `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP +); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `users` +-- + +CREATE TABLE IF NOT EXISTS `users` ( + `id` INT AUTO_INCREMENT PRIMARY KEY, + `name` VARCHAR(255) NOT NULL, + `email` VARCHAR(255) NOT NULL UNIQUE, + `password` VARCHAR(255) NOT NULL, + `role` VARCHAR(50) NOT NULL DEFAULT 'user', + `created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP +); diff --git a/db/config.php b/db/config.php index 89075af..014dddb 100644 --- a/db/config.php +++ b/db/config.php @@ -6,12 +6,40 @@ define('DB_USER', 'app_30908'); define('DB_PASS', '98b730aa-be6c-479d-a47d-e5e7abc49229'); function db() { - static $pdo; - if (!$pdo) { - $pdo = new PDO('mysql:host='.DB_HOST.';dbname='.DB_NAME.';charset=utf8mb4', DB_USER, DB_PASS, [ - PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, - PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, - ]); - } - return $pdo; + static $pdo; + if (!$pdo) { + try { + $pdo = new PDO('mysql:host=' . DB_HOST . ';dbname=' . DB_NAME . ';charset=utf8mb4', DB_USER, DB_PASS, [ + PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, + PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, + ]); + + // Create users table if it doesn't exist + $pdo->exec(" + CREATE TABLE IF NOT EXISTS `users` ( + `id` INT AUTO_INCREMENT PRIMARY KEY, + `name` VARCHAR(255) NOT NULL, + `email` VARCHAR(255) NOT NULL UNIQUE, + `password` VARCHAR(255) NOT NULL, + `role` VARCHAR(50) NOT NULL DEFAULT 'user', + `created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + "); + + // Create a default admin user if one doesn't exist + $stmt = $pdo->prepare("SELECT id FROM users WHERE email = ?"); + $stmt->execute(['admin']); + if ($stmt->fetchColumn() === false) { + $stmt = $pdo->prepare("INSERT INTO users (name, email, password, role) VALUES (?, ?, ?, ?)"); + $stmt->execute(['Admin', 'admin', password_hash('admin123', PASSWORD_DEFAULT), 'admin']); + } + + } catch (PDOException $e) { + // If the database doesn't exist, this will fail. + // This is a simple setup, so we'll just die. + // In a real app, you'd have a proper installer. + die("DB connection failed: " . $e->getMessage()); + } + } + return $pdo; } diff --git a/index.php b/index.php index f579519..9a37cf7 100644 --- a/index.php +++ b/index.php @@ -1,59 +1,15 @@ - - - - - - - AI Web App Generator - - + - - - - - - - - - - - - - - - - - - - - -
- -
- -

Build Your Web App in Minutes, Not Months

Describe your vision. Our AI generates the full-stack code, from frontend to database. You own it all.

- Start Building for Free + Start Building for Free Explore Features
@@ -126,18 +82,5 @@
-
- - -
- - - - - \ No newline at end of file + \ No newline at end of file diff --git a/login.php b/login.php new file mode 100644 index 0000000..e47a0db --- /dev/null +++ b/login.php @@ -0,0 +1,88 @@ +prepare("SELECT * FROM users WHERE email = ?"); + $stmt->execute([$email]); + $user = $stmt->fetch(); + + if ($user && password_verify($password, $user['password'])) { + $_SESSION['user_id'] = $user['id']; + $_SESSION['user_name'] = $user['name']; + $_SESSION['user_email'] = $user['email']; + $_SESSION['user_role'] = $user['role']; + header("Location: dashboard.php"); + exit(); + } else { + $errors[] = 'Invalid email or password.'; + } + } catch (PDOException $e) { + $errors[] = "Database error: " . $e->getMessage(); + } + } +} + +$pageTitle = "Login"; +include 'partials/header.php'; +?> + +
+
+
+
+
+

Log In to Your Account

+ + +
+ +

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

Don't have an account? Register here.

+
+
+
+
+
+
+ + diff --git a/logout.php b/logout.php new file mode 100644 index 0000000..be595a6 --- /dev/null +++ b/logout.php @@ -0,0 +1,22 @@ + + + + + + + + diff --git a/partials/header.php b/partials/header.php new file mode 100644 index 0000000..88c200f --- /dev/null +++ b/partials/header.php @@ -0,0 +1,56 @@ + + + + + + <?php echo isset($pageTitle) ? htmlspecialchars($pageTitle) . ' - ' : ''; ?>AI Web App Generator + + + + + + + + + +
+ +
+ +
diff --git a/privacy.php b/privacy.php index 87159c9..2ff5524 100644 --- a/privacy.php +++ b/privacy.php @@ -1,28 +1,35 @@ - - - - - - Privacy Policy - - - - -
-

Privacy Policy

-

This page is under construction.

- Go to Homepage + +
+
+
+

Privacy Policy

+

Last updated:

+ +

This page is under construction. A full privacy policy will be available here soon.

+ +

1. Information We Collect

+

We will detail the information we collect, such as personal data provided during registration (name, email) and data collected automatically (IP address, browser type).

+ +

2. How We Use Your Information

+

We will explain how we use the collected data, for purposes like providing and improving our service, communicating with users, and ensuring security.

+ +

3. Data Sharing and Disclosure

+

We will clarify the circumstances under which user data might be shared with third parties, such as service providers or for legal reasons.

+ +

4. Data Security

+

We will describe the measures we take to protect user data from unauthorized access or disclosure.

+ +

5. Your Rights

+

We will outline the rights users have regarding their data, such as accessing, correcting, or deleting their personal information.

+ +

Contact Us

+

If you have any questions about this Privacy Policy, you can contact us via the contact form.

+
- - +
+ + diff --git a/register.php b/register.php new file mode 100644 index 0000000..a5f5fbf --- /dev/null +++ b/register.php @@ -0,0 +1,105 @@ +prepare("SELECT id FROM users WHERE email = ?"); + $stmt->execute([$email]); + if ($stmt->fetch()) { + $errors[] = 'An account with this email already exists.'; + } else { + $hashed_password = password_hash($password, PASSWORD_DEFAULT); + $stmt = $pdo->prepare("INSERT INTO users (name, email, password) VALUES (?, ?, ?)"); + $stmt->execute([$name, $email, $hashed_password]); + + // Send welcome email + $subject = "Welcome to AI Web App Generator!"; + $htmlBody = "

Welcome, {$name}!

Thank you for registering. You can now log in and start creating your web application.

"; + $textBody = "Welcome, {$name}! Thank you for registering. You can now log in and start creating your web application."; + MailService::sendMail($email, $subject, $htmlBody, $textBody); + + $success = 'Registration successful! You can now log in.'; + } + } catch (PDOException $e) { + $errors[] = "Database error: " . $e->getMessage(); + } + } +} + +$pageTitle = "Register"; +include 'partials/header.php'; +?> + +
+
+
+
+
+

Create Your Account

+ + +
+ +

+ +
+ + + +
+

+
+ +
+
+ + +
+
+ + +
+
+ + +
Password must be at least 8 characters long.
+
+
+ +
+
+ +
+
+
+
+
+ +