diff --git a/assets/docs/cvs/placeholder.pdf b/assets/docs/cvs/placeholder.pdf new file mode 100644 index 0000000..ed97684 --- /dev/null +++ b/assets/docs/cvs/placeholder.pdf @@ -0,0 +1 @@ +%PDF-1.4 Placeholder CV \ No newline at end of file diff --git a/db/migrations/18_add_cv_and_country_to_users.sql b/db/migrations/18_add_cv_and_country_to_users.sql new file mode 100644 index 0000000..5ac84f0 --- /dev/null +++ b/db/migrations/18_add_cv_and_country_to_users.sql @@ -0,0 +1,3 @@ +-- Add CV and Country fields to users table +ALTER TABLE users ADD COLUMN IF NOT EXISTS cv_url VARCHAR(255) DEFAULT NULL; +ALTER TABLE users ADD COLUMN IF NOT EXISTS country VARCHAR(100) DEFAULT NULL; diff --git a/edit_profile.php b/edit_profile.php index 4d21e34..073c00d 100644 --- a/edit_profile.php +++ b/edit_profile.php @@ -14,6 +14,9 @@ $platformName = defined('PLATFORM_NAME') ? PLATFORM_NAME : 'Gatsby'; $error = ''; $success = ''; +// Centralized country list +$countries = require 'includes/countries.php'; + if ($_SERVER['REQUEST_METHOD'] === 'POST') { if (isset($_POST['action']) && $_POST['action'] === 'update_profile') { $full_name = trim($_POST['full_name']); @@ -22,17 +25,47 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $degree_program = trim($_POST['degree_program']); $skills = trim($_POST['skills']); $startup_industries = trim($_POST['startup_industries']); + $country = $_POST['country'] ?? ''; - if ($full_name) { - $stmt = db()->prepare("UPDATE users SET full_name = ?, bio = ?, university = ?, degree_program = ?, skills = ?, startup_industries = ? WHERE id = ?"); - $stmt->execute([$full_name, $bio, $university, $degree_program, $skills, $startup_industries, $user_id]); - $success = "Profile updated successfully!"; - // Refresh user data - $stmt = db()->prepare("SELECT * FROM users WHERE id = ?"); - $stmt->execute([$user_id]); - $user = $stmt->fetch(); - } else { - $error = "Full name is required."; + $cv_url = $user['cv_url']; + + // Handle CV Upload + if (isset($_FILES['cv_file']) && $_FILES['cv_file']['error'] === UPLOAD_ERR_OK) { + $file_tmp = $_FILES['cv_file']['tmp_name']; + $file_name = $_FILES['cv_file']['name']; + $file_ext = strtolower(pathinfo($file_name, PATHINFO_EXTENSION)); + $allowed_exts = ['pdf', 'doc', 'docx']; + + if (in_array($file_ext, $allowed_exts)) { + $upload_dir = 'assets/docs/cvs/'; + if (!is_dir($upload_dir)) { + mkdir($upload_dir, 0777, true); + } + $new_file_name = 'cv_' . $user_id . '_' . time() . '.' . $file_ext; + $target_path = $upload_dir . $new_file_name; + + if (move_uploaded_file($file_tmp, $target_path)) { + $cv_url = $target_path; + } else { + $error = "Failed to upload CV."; + } + } else { + $error = "Invalid CV file type. Only PDF, DOC, and DOCX are allowed."; + } + } + + if (!$error) { + if ($full_name) { + $stmt = db()->prepare("UPDATE users SET full_name = ?, bio = ?, university = ?, degree_program = ?, skills = ?, startup_industries = ?, country = ?, cv_url = ? WHERE id = ?"); + $stmt->execute([$full_name, $bio, $university, $degree_program, $skills, $startup_industries, $country, $cv_url, $user_id]); + $success = "Profile updated successfully!"; + // Refresh user data + $stmt = db()->prepare("SELECT * FROM users WHERE id = ?"); + $stmt->execute([$user_id]); + $user = $stmt->fetch(); + } else { + $error = "Full name is required."; + } } } elseif (isset($_POST['action']) && $_POST['action'] === 'delete_account') { try { @@ -109,7 +142,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {