addind username box

main
Grim0o5 6 months ago
parent fa2468352e
commit b54903e06e
  1. 18
      jobseekerprofile.php
  2. 7
      updateemployeeprofile.php
  3. 8
      updateprofile.php

@ -15,7 +15,7 @@ $user_id = $_SESSION['user_id']; // Get user ID from the session
// Fetch user data from the database // Fetch user data from the database
$query = "SELECT u.firstname, u.lastname, u.email, u.phone, $query = "SELECT u.firstname, u.lastname, u.email, u.phone,u.username,
j.skills, j.experience, j.education, j.location j.skills, j.experience, j.education, j.location
FROM users u FROM users u
LEFT JOIN job_seekers j ON u.user_id = j.user_id LEFT JOIN job_seekers j ON u.user_id = j.user_id
@ -101,13 +101,27 @@ if ($result->num_rows > 0) {
> >
</div> </div>
<!-- username -->
<div class="form-control">
<label class="label">
<span class="label-text">username</span>
</label>
<input
type="text"
name="username"
value="<?php echo isset($user['username']) ? htmlspecialchars($user['username']) : ''; ?>"
class="input input-bordered w-full"
required
>
</div>
<!-- Phone --> <!-- Phone -->
<div class="form-control"> <div class="form-control">
<label class="label"> <label class="label">
<span class="label-text">Phone Number</span> <span class="label-text">Phone Number</span>
</label> </label>
<input <input
type="tel" type="number"
name="phone" name="phone"
value="<?php echo isset($user['phone']) ? htmlspecialchars($user['phone']) : ''; ?>" value="<?php echo isset($user['phone']) ? htmlspecialchars($user['phone']) : ''; ?>"
class="input input-bordered w-full" class="input input-bordered w-full"

@ -18,7 +18,7 @@ if (isset($_POST['update'])) {
$username = trim($_POST['username']); $username = trim($_POST['username']);
$address = trim($_POST['address']); $address = trim($_POST['address']);
try { try {
$conn->begin_transaction(); $conn->begin_transaction();
@ -32,6 +32,7 @@ if (isset($_POST['update'])) {
} }
$stmt_users->bind_param("sssssi", $first_name, $last_name, $email, $phone, $username,$user_id); $stmt_users->bind_param("sssssi", $first_name, $last_name, $email, $phone, $username,$user_id);
if (!$stmt_users->execute()) { if (!$stmt_users->execute()) {
throw new Exception("Error updating users table: " . $stmt_users->error); throw new Exception("Error updating users table: " . $stmt_users->error);
} }
@ -75,8 +76,8 @@ if (isset($_POST['update'])) {
} }
$conn->commit(); $conn->commit();
$_SESSION['success_message'] = "Profile updated successfully!"; echo "<script>alert('Profile updated successfully! Relogin to see the changes'); window.location.href = 'login';</script>";
header("Location: employerprofile");
exit(); exit();
} catch (Exception $e) { } catch (Exception $e) {

@ -14,6 +14,7 @@ if (isset($_POST['update'])) {
$first_name = trim($_POST['first_name']); $first_name = trim($_POST['first_name']);
$last_name = trim($_POST['last_name']); $last_name = trim($_POST['last_name']);
$email = trim($_POST['email']); $email = trim($_POST['email']);
$username = trim($_POST['username']);
$phone = trim($_POST['phone']); $phone = trim($_POST['phone']);
$skills = trim($_POST['skills']); $skills = trim($_POST['skills']);
$experience = trim($_POST['experience']); $experience = trim($_POST['experience']);
@ -25,13 +26,13 @@ if (isset($_POST['update'])) {
// 1. First update the users table // 1. First update the users table
$query_users = "UPDATE users $query_users = "UPDATE users
SET firstname = ?, lastname = ?, email = ?, phone = ? SET firstname = ?, lastname = ?, email = ?, phone = ? ,username =?
WHERE user_id = ?"; WHERE user_id = ?";
$stmt_users = $conn->prepare($query_users); $stmt_users = $conn->prepare($query_users);
if (!$stmt_users) { if (!$stmt_users) {
throw new Exception("Prepare failed for users table: " . $conn->error); 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()) { if (!$stmt_users->execute()) {
throw new Exception("Error updating users table: " . $stmt_users->error); throw new Exception("Error updating users table: " . $stmt_users->error);
@ -81,8 +82,7 @@ if (isset($_POST['update'])) {
} }
$conn->commit(); $conn->commit();
$_SESSION['success_message'] = "Profile updated successfully!"; echo "<script>alert('Profile updated successfully! relogin to see the changes'); window.location.href = 'login';</script>";
header("Location: jobseekerprofile.php");
exit(); exit();
} catch (Exception $e) { } catch (Exception $e) {

Loading…
Cancel
Save