You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
YOLO/employerprofile.php

139 lines
5.2 KiB

<?php
session_start(); // Start the session
// Include your database connection
include 'connect.php';
// Ensure the user is logged in
if (!isset($_SESSION['user_id'])) {
header("Location: login.php"); // Redirect to login if the user is not logged in
exit();
}
$user_id = $_SESSION['user_id']; // Get user ID from the session
// Fetch user data from the database
$query = "SELECT u.firstname, u.lastname, u.email, u.phone,
e.company_name, e.company_email, e.company_address,
e.industry
FROM users u
LEFT JOIN employers e ON u.user_id = e.user_id
WHERE u.user_id = ?";
$stmt = $conn->prepare($query);
if (!$stmt) {
die("Prepare failed: " . $conn->error);
}
$stmt->bind_param("i", $user_id);
if (!$stmt->execute()) {
die("Query execution failed: " . $stmt->error);
}
$result = $stmt->get_result();
// Check if the user data was found
if ($result->num_rows > 0) {
$user = $result->fetch_assoc();
} else {
$user = []; // Set $user to an empty array to avoid errors
}
?>
<!DOCTYPE html>
<html lang="en" data-theme="light">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Update Profile</title>
<link href="https://cdnjs.cloudflare.com/ajax/libs/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/daisyui/2.6.0/full.css" rel="stylesheet">
</head>
<body class="min-h-screen bg-base-200">
<?php include 'navbar.php' ?>
<div class="container mx-auto px-4 py-8">
<div class="card max-w-2xl mx-auto bg-base-100 shadow-xl">
<div class="card-body">
<h2 class="card-title text-2xl font-bold text-center mb-6">Employer Profile</h2>
<form method="POST" action="updateemployeeprofile.php" enctype="multipart/form-data" class="space-y-6">
<!-- First Name -->
<div class="form-control">
<label class="label">
<span class="label-text">First Name</span>
</label>
<input
type="text"
name="first_name"
value="<?php echo isset($user['firstname']) ? $user['firstname'] : ''; ?>"
class="input input-bordered w-full"
required
>
</div>
<!-- Last Name -->
<div class="form-control">
<label class="label">
<span class="label-text">Last Name</span>
</label>
<input
type="text"
name="last_name"
value="<?php echo isset($user['lastname']) ? $user['lastname'] : ''; ?>"
class="input input-bordered w-full"
required
>
</div>
<!-- Email -->
<div class="form-control">
<label class="label">
<span class="label-text">Email</span>
</label>
<input
type="email"
name="email"
value="<?php echo isset($user['email']) ? $user['email'] : ''; ?>"
class="input input-bordered w-full"
required
>
</div>
<!-- Phone Number -->
<div class="form-control">
<label class="label">
<span class="label-text">Phone Number</span>
</label>
<input
type="tel"
name="phone"
value="<?php echo isset($user['phone']) ? $user['phone'] : ''; ?>"
class="input input-bordered w-full"
required
>
</div>
<!-- Company Address -->
<div class="form-control">
<label class="label">
<span class="label-text">Company Address</span>
</label>
<input
type="text"
name="company_address"
value="<?php echo isset($user['company_address']) ? $user['company_address'] : ''; ?>"
class="input input-bordered w-full"
required
>
</div>
<!-- Submit Button -->
<div class="form-control mt-8">
<button type="submit" name="update" class="btn btn-primary w-full">Update Profile</button>
</div>
</form>
</div>
</div>
</div>
<?php include 'footer.php'?>
</body>
</html>