diff --git a/assets/css/custom.css b/assets/css/custom.css new file mode 100644 index 0000000..6348bc4 --- /dev/null +++ b/assets/css/custom.css @@ -0,0 +1,119 @@ +/* assets/css/custom.css */ + +@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700&display=swap'); + +:root { + --background-color: #121212; + --surface-color: #1E1E1E; + --primary-color: #03DAC6; + --secondary-color: #BB86FC; + --text-color: #E1E1E1; + --subtle-text-color: #888888; + --border-radius: 0.5rem; +} + +body { + background-color: var(--background-color); + color: var(--text-color); + font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; +} + +.navbar-dark .navbar-nav .nav-link { + color: var(--text-color); +} + +.navbar-dark .navbar-nav .nav-link:hover { + color: var(--primary-color); +} + +.hero-section { + background-image: linear-gradient(rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.7)), url('https://picsum.photos/seed/techhero/1600/900'); + background-size: cover; + background-position: center; + padding: 10rem 0; + color: white; +} + +.hero-section .display-4 { + font-weight: 700; +} + +.btn-primary { + background-color: var(--primary-color); + border-color: var(--primary-color); + color: #000; + font-weight: 500; + padding: 0.75rem 1.5rem; + border-radius: var(--border-radius); + transition: background-color 0.3s ease, transform 0.2s ease; +} + +.btn-primary:hover { + background-color: #01bfa5; + border-color: #01bfa5; + transform: translateY(-2px); +} + +.btn-secondary { + background-color: transparent; + border-color: var(--primary-color); + color: var(--primary-color); +} + +.btn-secondary:hover { + background-color: var(--primary-color); + border-color: var(--primary-color); + color: #000; +} + +.product-card { + background-color: var(--surface-color); + border: 1px solid #2a2a2a; + border-radius: var(--border-radius); + transition: transform 0.3s ease, box-shadow 0.3s ease; + overflow: hidden; +} + +.product-card:hover { + transform: translateY(-5px); + box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2); +} + +.product-card .card-img-top { + border-bottom: 1px solid #2a2a2a; +} + +.product-card .card-body { + padding: 1.5rem; +} + +.product-card .card-title { + color: var(--text-color); + font-weight: 500; +} + +.product-card .card-text { + color: var(--subtle-text-color); +} + +.product-price { + color: var(--primary-color); + font-size: 1.5rem; + font-weight: 700; +} + +.footer { + background-color: var(--surface-color); + padding: 3rem 0; + margin-top: 5rem; + border-top: 1px solid #2a2a2a; +} + +.footer a { + color: var(--subtle-text-color); + text-decoration: none; +} + +.footer a:hover { + color: var(--primary-color); +} diff --git a/assets/js/main.js b/assets/js/main.js new file mode 100644 index 0000000..584738a --- /dev/null +++ b/assets/js/main.js @@ -0,0 +1,10 @@ +document.addEventListener('DOMContentLoaded', function () { + const addToCartButtons = document.querySelectorAll('.add-to-cart-btn'); + + addToCartButtons.forEach(button => { + button.addEventListener('click', function (event) { + event.preventDefault(); + alert('Added to cart! (Full functionality coming soon)'); + }); + }); +}); diff --git a/db/config.php b/db/config.php index a0e6a07..9213956 100644 --- a/db/config.php +++ b/db/config.php @@ -1,17 +1,52 @@ PDO::ERRMODE_EXCEPTION, - PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, - ]); - } - return $pdo; -} +// --- Database Credentials --- +// Note: In a real production environment, use environment variables +// or a secure secrets management system instead of hardcoding credentials. +define('DB_HOST', '127.0.0.1'); +define('DB_NAME', 'webapp_db'); +define('DB_USER', 'webapp_user'); +define('DB_PASS', 'password'); // IMPORTANT: Use a strong, unique password in production + +/** + * Establishes a PDO database connection. + * + * @return PDO|null A PDO connection object on success, or null on failure. + */ +function db_connect() { + static $pdo = null; + + if ($pdo instanceof PDO) { + return $pdo; + } + + $dsn = 'mysql:host=' . DB_HOST . ';dbname=' . DB_NAME . ';charset=utf8mb4'; + $options = [ + PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, + PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, + PDO::ATTR_EMULATE_PREPARES => false, + ]; + + try { + // Create a new database and user if they don't exist. + // This is for demonstration purposes to make setup easier. + // In a production environment, database and user management should be handled separately. + $rootPdo = new PDO('mysql:host=' . DB_HOST, 'root', ''); + $rootPdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + $rootPdo->exec('CREATE DATABASE IF NOT EXISTS ' . DB_NAME); + $rootPdo->exec("CREATE USER IF NOT EXISTS '" . DB_USER . "'@'localhost' IDENTIFIED BY '" . DB_PASS . "'"); + $rootPdo->exec('GRANT ALL PRIVILEGES ON ' . DB_NAME . '.* TO '' . DB_USER . ''@'localhost''); + $rootPdo = null; + + $pdo = new PDO($dsn, DB_USER, DB_PASS, $options); + return $pdo; + } catch (PDOException $e) { + // In a real app, you would log this error and show a generic error page. + // For development, it's useful to see the error. + error_log('Database Connection Error: ' . $e->getMessage()); + // Never echo connection errors in production + // echo 'Connection failed: ' . $e->getMessage(); + return null; + } +} \ No newline at end of file diff --git a/db/setup.php b/db/setup.php new file mode 100644 index 0000000..69cabda --- /dev/null +++ b/db/setup.php @@ -0,0 +1,87 @@ +exec("\n CREATE TABLE IF NOT EXISTS products (\n id INT AUTO_INCREMENT PRIMARY KEY,\n name VARCHAR(255) NOT NULL,\n description TEXT,\n price DECIMAL(10, 2) NOT NULL,\n image_url VARCHAR(255),\n stock INT DEFAULT 0,\n created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP\n );\n "); + + // Check if the table is empty before inserting data + $stmt = $pdo->query('SELECT COUNT(*) FROM products'); + if ($stmt->fetchColumn() == 0) { + // Insert sample products + $products = [ + [ + 'name' => 'QuantumBook Pro', + 'description' => 'The next generation of laptops with quantum processing power. Sleek, powerful, and unbelievably fast.', + 'price' => 2499.99, + 'image_url' => 'https://picsum.photos/seed/laptop/600/600', + 'stock' => 50 + ], + [ + 'name' => 'NovaPhone X', + 'description' => 'A revolutionary smartphone with a holographic display and an AI-powered camera system.', + 'price' => 1299.99, + 'image_url' => 'https://picsum.photos/seed/phone/600/600', + 'stock' => 120 + ], + [ + 'name' => 'AuraBuds Pro', + 'description' => 'Immersive sound experience with active noise-cancellation and a 48-hour battery life.', + 'price' => 249.99, + 'image_url' => 'https://picsum.photos/seed/headphones/600/600', + 'stock' => 300 + ], + [ + 'name' => 'GalaxyPad 5', + 'description' => 'A versatile tablet for work and play, featuring a stunning 12.9-inch display and stylus support.', + 'price' => 799.99, + 'image_url' => 'https://picsum.photos/seed/tablet/600/600', + 'stock' => 80 + ], + [ + 'name' => 'ChronoWatch 2', + 'description' => 'A smart watch that tracks your fitness, sleep, and notifications with a classic, elegant design.', + 'price' => 449.99, + 'image_url' => 'https://picsum.photos/seed/watch/600/600', + 'stock' => 150 + ], + [ + 'name' => 'VR-Xperience Helmet', + 'description' => 'Step into new worlds with this high-fidelity virtual reality helmet. True immersion awaits.', + 'price' => 999.99, + 'image_url' => 'https://picsum.photos/seed/vr/600/600', + 'stock' => 40 + ] + ]; + + $stmt = $pdo->prepare('INSERT INTO products (name, description, price, image_url, stock) VALUES (?, ?, ?, ?, ?)'); + foreach ($products as $product) { + $stmt->execute([$product['name'], $product['description'], $product['price'], $product['image_url'], $product['stock']]); + } + } + + } catch (Exception $e) { + error_log('Database Setup Error: ' . $e->getMessage()); + // In a real app, you might want to die() here or show a friendly error page + // as the application cannot function without the database. + } +} + +// If the script is run directly from the command line, execute the setup. +if (php_sapi_name() === 'cli') { + echo "Setting up database...\n"; + setup_database(); + echo "Database setup complete.\n"; +} diff --git a/index.php b/index.php index 6f7ffab..c1850e6 100644 --- a/index.php +++ b/index.php @@ -1,131 +1,129 @@ query('SELECT id, name, description, price, image_url FROM products ORDER BY created_at DESC'); + $products = $stmt->fetchAll(); + } else { + $db_error = "Could not connect to the database."; + } +} catch (Exception $e) { + $db_error = "Error fetching products: " . $e->getMessage(); + error_log($db_error); +} -$phpVersion = PHP_VERSION; -$now = date('Y-m-d H:i:s'); ?> - + - - - New Style - - - - + + + TechCore - Cutting-Edge Technology Products + + + + + + + + + + + + + + + + + + + + + + -
-
-

Analyzing your requirements and generating your website…

-
- Loading… -
-

AI is collecting your requirements and applying the first changes.

-

This page will update automatically as the plan is implemented.

-

Runtime: PHP — UTC

-
-
- + + + + + +
+
+

Cutting-Edge Tech

+

Explore the future of technology. High-performance gadgets for work, play, and everything in between.

+ Shop Now +
+
+ + +
+

Our Products

+ + +
Error: . Please check server logs.
+ +
No products found. The admin can add products to the inventory.
+ +
+ +
+
+ <?php echo htmlspecialchars($product['name']); ?> +
+
+

+
+

$

+ Add to Cart +
+
+
+
+ +
+ +
+ + + + + + + + - + \ No newline at end of file