prepare("SELECT id FROM users WHERE username = ?"); $stmt->execute([$username]); if ($stmt->fetch()) { $error = 'Username already exists.'; } else { $hashed_password = password_hash($password, PASSWORD_DEFAULT); $stmt = db()->prepare("INSERT INTO users (username, password) VALUES (?, ?)"); $stmt->execute([$username, $hashed_password]); $success = 'Registration successful! You can now log in.'; } } catch (PDOException $e) { if ($e->getCode() === '42S02') { // Base table not found $error = 'The application has not been fully set up. Please run the database migrations.'; } else { $error = "Error: " . $e->getMessage(); } } } } ?> Register - My Blog

My Blog

Create an Account

Login