task 1
task 1
task 1
bash
Copy code
/job-application-tracker
/assets
/css
- style.css
/js
- script.js
/includes
- db.php
- header.php
- footer.php
- session.php
/pages
- index.php
- login.php
- register.php
- dashboard.php
- add_application.php
- edit_application.php
- view_application.php
/config
- config.php
2. Database Setup
First, we’ll set up the MySQL database. You need two tables: users and
applications.
USE job_tracker;
-- Users Table
CREATE TABLE users (
id INT AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(100) NOT NULL,
email VARCHAR(100) NOT NULL UNIQUE,
password VARCHAR(255) NOT NULL
);
-- Applications Table
CREATE TABLE applications (
application_id INT AUTO_INCREMENT PRIMARY KEY,
user_id INT NOT NULL,
job_title VARCHAR(255) NOT NULL,
company_name VARCHAR(255) NOT NULL,
status ENUM('applied', 'under review', 'interview', 'offer', 'rejected') NOT
NULL,
follow_up_date DATE,
notes TEXT,
FOREIGN KEY (user_id) REFERENCES users(id)
);
Explanation:
users table stores user credentials (ID, username, email, password).
applications table stores job application data, with a foreign key user_id linking
back to the users table.
3. Backend Implementation (PHP)
3.1 Database Connection (includes/db.php)
php
Copy code
<?php
$servername = "localhost";
$username = "root"; // Change if necessary
$password = ""; // Change if necessary
$dbname = "job_tracker";
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
?>
3.2 User Registration (register.php)
php
Copy code
<?php
include('includes/db.php');
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$username = $_POST['username'];
$email = $_POST['email'];
$password = password_hash($_POST['password'], PASSWORD_DEFAULT);
<form method="post">
<input type="text" name="username" placeholder="Username" required>
<input type="email" name="email" placeholder="Email" required>
<input type="password" name="password" placeholder="Password" required>
<button type="submit">Register</button>
</form>
3.3 User Login (login.php)
php
Copy code
<?php
session_start();
include('includes/db.php');
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$email = $_POST['email'];
$password = $_POST['password'];
<form method="post">
<input type="email" name="email" placeholder="Email" required>
<input type="password" name="password" placeholder="Password" required>
<button type="submit">Login</button>
</form>
4. Frontend Implementation
4.1 Dashboard (dashboard.php)
Display a summary of job applications with the ability to add new applications and
view application details.
php
Copy code
<?php
session_start();
include('includes/db.php');
if (!isset($_SESSION['user_id'])) {
header("Location: login.php");
}
$user_id = $_SESSION['user_id'];
$sql = "SELECT * FROM applications WHERE user_id = $user_id";
$result = $conn->query($sql);
?>
<table>
<tr>
<th>Job Title</th>
<th>Company</th>
<th>Status</th>
<th>Follow-up Date</th>
<th>Actions</th>
</tr>
<?php while($row = $result->fetch_assoc()) { ?>
<tr>
<td><?php echo $row['job_title']; ?></td>
<td><?php echo $row['company_name']; ?></td>
<td><?php echo $row['status']; ?></td>
<td><?php echo $row['follow_up_date']; ?></td>
<td><a href="view_application.php?id=<?php echo $row['application_id'];
?>">View</a> | <a href="edit_application.php?id=<?php echo
$row['application_id']; ?>">Edit</a></td>
</tr>
<?php } ?>
</table>
5. Job Application Management
5.1 Add New Application (add_application.php)
Form to add a new job application.
php
Copy code
<?php
session_start();
include('includes/db.php');
if (!isset($_SESSION['user_id'])) {
header("Location: login.php");
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$job_title = $_POST['job_title'];
$company_name = $_POST['company_name'];
$status = $_POST['status'];
$follow_up_date = $_POST['follow_up_date'];
$notes = $_POST['notes'];
$user_id = $_SESSION['user_id'];
<form method="post">
<input type="text" name="job_title" placeholder="Job Title" required>
<input type="text" name="company_name" placeholder="Company Name" required>
<select name="status">
<option value="applied">Applied</option>
<option value="under review">Under Review</option>
<option value="interview">Interview</option>
<option value="offer">Offer</option>
<option value="rejected">Rejected</option>
</select>
<input type="date" name="follow_up_date">
<textarea name="notes" placeholder="Additional Notes"></textarea>
<button type="submit">Save</button>
</form>
5.2 Edit Application (edit_application.php)
Allow users to edit their job application.
php
Copy code
<?php
session_start();
include('includes/db.php');
if (!isset($_SESSION['user_id'])) {
header("Location: login.php");
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$application_id = $_POST['application_id'];
$job_title = $_POST['job_title'];
$company_name = $_POST['company_name'];
$status = $_POST['status'];
$follow_up_date = $_POST['follow_up_date'];
$notes = $_POST['notes'];
<form method="post">
<input type="hidden" name="application_id" value="<?php echo
$application['application_id']; ?>">
<input type="text" name="job_title" value="<?php echo
$application['job_title']; ?>" required>
<input type="text" name="company_name" value="<?php echo
$application['company_name']; ?>" required>
<select name="status">
<option value="applied" <?php echo $application['status'] == 'applied' ?
'selected' : ''; ?>>Applied</option>
<option value="under review" <?php echo $application['status'] == 'under
review' ? 'selected' : ''; ?>>Under Review</option>
<option value="interview" <?php echo $application['status'] ==
'interview' ? 'selected' : ''; ?>>Interview</option>
<option value="offer" <?php echo $application['status'] == 'offer' ?
'selected' : ''; ?>>Offer</option>
<option value="rejected" <?php echo $application['status'] == 'rejected' ?
'selected' : ''; ?>>Rejected</option>
</select>
<input type="date" name="follow_up_date" value="<?php echo
$application['follow_up_date']; ?>">
<textarea name="notes"><?php echo $application['notes']; ?></textarea>
<button type="submit">Save</button>
</form>
6. Additional Features
6.1 Search & Filter
Use JavaScript or PHP to implement search and filter functionality.
6.2 Notifications & Reminders
Use PHP's mail() function to send reminder emails or implement browser
notifications using JavaScript.
Final Notes:
This step-by-step guide gives a basic structure for building a Job Application
Tracker website.
You said:
4. Edit and Delete Applications:
o Options to update the details of a job application, such as changing the status,
modifying deadlines, or adding additional notes.
o Users can delete applications they no longer need to track.
5. Search and Filter:
o Search functionality to locate specific job applications based on keywords like
company name, position, or status.
o Filters to view applications by specific status categories (e.g., show only
"interviews" or "offers").
6. Notifications and Reminders:
php
Copy code
// edit_application.php
<?php
session_start();
include('includes/db.php');
if (!isset($_SESSION['user_id'])) {
header("Location: login.php");
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Get the form data
$application_id = $_POST['application_id'];
$job_title = $_POST['job_title'];
$company_name = $_POST['company_name'];
$status = $_POST['status'];
$follow_up_date = $_POST['follow_up_date'];
$notes = $_POST['notes'];
// Update query
$sql = "UPDATE applications SET job_title = ?, company_name = ?, status = ?,
follow_up_date = ?, notes = ? WHERE application_id = ?";
$stmt = $conn->prepare($sql);
$stmt->bind_param("sssssi", $job_title, $company_name, $status,
$follow_up_date, $notes, $application_id);
if ($stmt->execute()) {
header("Location: dashboard.php");
} else {
echo "Error updating application: " . $stmt->error;
}
} else {
// Retrieve the application data to pre-fill the form
$application_id = $_GET['id'];
$sql = "SELECT * FROM applications WHERE application_id = $application_id";
$result = $conn->query($sql);
$application = $result->fetch_assoc();
}
?>
<form method="post">
<input type="hidden" name="application_id" value="<?php echo
$application['application_id']; ?>">
<input type="text" name="job_title" value="<?php echo
$application['job_title']; ?>" required>
<input type="text" name="company_name" value="<?php echo
$application['company_name']; ?>" required>
<select name="status">
<option value="applied" <?php echo $application['status'] == 'applied' ?
'selected' : ''; ?>>Applied</option>
<option value="under review" <?php echo $application['status'] == 'under
review' ? 'selected' : ''; ?>>Under Review</option>
<option value="interview" <?php echo $application['status'] ==
'interview' ? 'selected' : ''; ?>>Interview</option>
<option value="offer" <?php echo $application['status'] == 'offer' ?
'selected' : ''; ?>>Offer</option>
<option value="rejected" <?php echo $application['status'] == 'rejected' ?
'selected' : ''; ?>>Rejected</option>
</select>
<input type="date" name="follow_up_date" value="<?php echo
$application['follow_up_date']; ?>">
<textarea name="notes"><?php echo $application['notes']; ?></textarea>
<button type="submit">Save Changes</button>
</form>
4.2 Delete Application
This will allow the user to delete a job application from the system.
php
Copy code
// delete_application.php
<?php
session_start();
include('includes/db.php');
if (!isset($_SESSION['user_id'])) {
header("Location: login.php");
}
if (isset($_GET['id'])) {
$application_id = $_GET['id'];
// Delete query
$sql = "DELETE FROM applications WHERE application_id = ?";
$stmt = $conn->prepare($sql);
$stmt->bind_param("i", $application_id);
if ($stmt->execute()) {
header("Location: dashboard.php");
} else {
echo "Error deleting application: " . $stmt->error;
}
}
?>
To integrate the "Delete" button into the application list (in dashboard.php), you
can add:
php
Copy code
<td><a href="view_application.php?id=<?php echo $row['application_id'];
?>">View</a> | <a href="edit_application.php?id=<?php echo
$row['application_id']; ?>">Edit</a> | <a href="delete_application.php?id=<?php
echo $row['application_id']; ?>" onclick="return confirm('Are you sure you want to
delete this application?');">Delete</a></td>
5. Search and Filter
We will add functionality to search and filter job applications based on keywords
(like company name, job title, or status).
php
Copy code
// dashboard.php
<?php
session_start();
include('includes/db.php');
if (!isset($_SESSION['user_id'])) {
header("Location: login.php");
}
$user_id = $_SESSION['user_id'];
$search_query = isset($_POST['search']) ? $_POST['search'] : '';
<form method="post">
<input type="text" name="search" value="<?php echo $search_query; ?>"
placeholder="Search by Job Title, Company, or Status">
<button type="submit">Search</button>
</form>
<table>
<tr>
<th>Job Title</th>
<th>Company</th>
<th>Status</th>
<th>Follow-up Date</th>
<th>Actions</th>
</tr>
<?php while($row = $result->fetch_assoc()) { ?>
<tr>
<td><?php echo $row['job_title']; ?></td>
<td><?php echo $row['company_name']; ?></td>
<td><?php echo $row['status']; ?></td>
<td><?php echo $row['follow_up_date']; ?></td>
<td><a href="view_application.php?id=<?php echo $row['application_id'];
?>">View</a> | <a href="edit_application.php?id=<?php echo
$row['application_id']; ?>">Edit</a> | <a href="delete_application.php?id=<?php
echo $row['application_id']; ?>" onclick="return confirm('Are you sure you want to
delete this application?');">Delete</a></td>
</tr>
<?php } ?>
</table>
5.2 Filter by Status
You can add a filter dropdown to the dashboard to view applications by their
status.
php
Copy code
// Filter form on dashboard.php
<form method="post">
<select name="status_filter">
<option value="">Select Status</option>
<option value="applied">Applied</option>
<option value="under review">Under Review</option>
<option value="interview">Interview</option>
<option value="offer">Offer</option>
<option value="rejected">Rejected</option>
</select>
<button type="submit">Filter</button>
</form>
<?php
$status_filter = isset($_POST['status_filter']) ? $_POST['status_filter'] : '';
php
Copy code
// Example: Check if follow-up date is within 2 days and send email reminder
$sql = "SELECT * FROM applications WHERE user_id = ? AND follow_up_date = CURDATE()
+ INTERVAL 2 DAY";
$stmt = $conn->prepare($sql);
$stmt->bind_param("i", $_SESSION['user_id']);
$stmt->execute();
$result = $stmt->get_result();
javascript
Copy code
// Check if any application's follow-up date is today or tomorrow
var applications = <?php echo json_encode($result->fetch_all(MYSQLI_ASSOC)); ?>;
applications.forEach(function(application) {
var followUpDate = new Date(application.follow_up_date);
var today = new Date();
var timeDifference = followUpDate - today;
sql
Copy code
CREATE TABLE application_history (
history_id INT AUTO_INCREMENT PRIMARY KEY,
application_id INT,
status ENUM('applied', 'under review', 'interview', 'offer', 'rejected'),
date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
notes TEXT,
FOREIGN KEY (application_id) REFERENCES applications(application_id)
);
7.2 Display the Timeline
For each application, display a timeline of updates:
php
Copy code
// view_application.php
<?php
// Fetch the history of this application
$application_id = $_GET['id'];
$sql = "SELECT * FROM application_history WHERE application_id = $application_id
ORDER BY date DESC";
$result = $conn->query($sql);
?>
<h2>Application Timeline</h2>
<ul>
<?php while($history = $result->fetch_assoc()) { ?>
<li><?php echo $history['status'] . " on " . $history['date']; ?> - <?php
echo $history['notes']; ?></li>
<?php } ?>
</ul>
Final Thoughts
With these implementations, you've got a full-featured job application tracker with
the ability to: