prepare("SELECT is_writer FROM users WHERE id = :user_id"); $stmt->execute(['user_id' => $user_id]); $is_writer = $stmt->fetchColumn(); $stmt = db()->prepare("SELECT status FROM writer_applications WHERE user_id = :user_id"); $stmt->execute(['user_id' => $user_id]); $application = $stmt->fetch(); if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['apply'])) { if (!$is_writer && (!$application || $application['status'] == 'rejected')) { $bio = trim($_POST['bio']); if (!empty($bio)) { try { $stmt = db()->prepare("INSERT INTO writer_applications (user_id, bio, status) VALUES (:user_id, :bio, 'pending') ON DUPLICATE KEY UPDATE bio = :bio, status = 'pending'"); $stmt->execute(['user_id' => $user_id, 'bio' => $bio]); $message = '
Tell us a bit about yourself and why you'd like to be a writer on our platform.