|
|
|
@ -15,7 +15,8 @@ if (isset($_POST['update'])) { |
|
|
|
|
$last_name = trim($_POST['last_name']); |
|
|
|
|
$email = trim($_POST['email']); |
|
|
|
|
$phone = trim($_POST['phone']); |
|
|
|
|
$company_address = trim($_POST['company_address']); |
|
|
|
|
$username = trim($_POST['username']); |
|
|
|
|
$address = trim($_POST['address']); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
@ -23,13 +24,13 @@ if (isset($_POST['update'])) { |
|
|
|
|
|
|
|
|
|
// 1. First update the users table |
|
|
|
|
$query_users = "UPDATE users |
|
|
|
|
SET firstname = ?, lastname = ?, email = ?, phone = ? |
|
|
|
|
SET firstname = ?, lastname = ?, email = ?, phone = ? ,username =? |
|
|
|
|
WHERE user_id = ?"; |
|
|
|
|
$stmt_users = $conn->prepare($query_users); |
|
|
|
|
if (!$stmt_users) { |
|
|
|
|
throw new Exception("Prepare failed for users table: " . $conn->error); |
|
|
|
|
} |
|
|
|
|
$stmt_users->bind_param("ssssi", $first_name, $last_name, $email, $phone, $user_id); |
|
|
|
|
$stmt_users->bind_param("sssssi", $first_name, $last_name, $email, $phone, $username,$user_id); |
|
|
|
|
|
|
|
|
|
if (!$stmt_users->execute()) { |
|
|
|
|
throw new Exception("Error updating users table: " . $stmt_users->error); |
|
|
|
@ -48,29 +49,29 @@ if (isset($_POST['update'])) { |
|
|
|
|
// Update existing record |
|
|
|
|
$employer_query = "UPDATE employers |
|
|
|
|
SET |
|
|
|
|
company_address = ? |
|
|
|
|
address = ? |
|
|
|
|
|
|
|
|
|
WHERE user_id = ?"; |
|
|
|
|
} else { |
|
|
|
|
// Insert new record |
|
|
|
|
$employer_query = "INSERT INTO employers |
|
|
|
|
( company_address, user_id) |
|
|
|
|
( address, user_id) |
|
|
|
|
VALUES (?, ?)"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$stmt_employers = $conn->prepare($employer_query); |
|
|
|
|
if (!$stmt_employers) { |
|
|
|
|
throw new Exception("Prepare failed for job_seekers table: " . $conn->error); |
|
|
|
|
throw new Exception("Prepare failed for Employer table: " . $conn->error); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Same binding for both UPDATE and INSERT |
|
|
|
|
$stmt_employers->bind_param("si", |
|
|
|
|
$company_address, |
|
|
|
|
$address, |
|
|
|
|
$user_id |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
if (!$stmt_employers->execute()) { |
|
|
|
|
throw new Exception("Error with job_seekers table: " . $stmt_employers->error); |
|
|
|
|
throw new Exception("Error with E ployers table: " . $stmt_employers->error); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$conn->commit(); |
|
|
|
|