task 1

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 11

1.

Set up the Project Structure


Create the following file/folder structure for your project:

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.

SQL for Database:


sql
Copy code
CREATE DATABASE job_tracker;

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";

$conn = new mysqli($servername, $username, $password, $dbname);

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);

$sql = "INSERT INTO users (username, email, password) VALUES ('$username',


'$email', '$password')";

if ($conn->query($sql) === TRUE) {


header("Location: login.php");
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
}
?>

<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'];

$sql = "SELECT * FROM users WHERE email = '$email'";


$result = $conn->query($sql);
if ($result->num_rows > 0) {
$user = $result->fetch_assoc();
if (password_verify($password, $user['password'])) {
$_SESSION['user_id'] = $user['id'];
header("Location: dashboard.php");
} else {
echo "Invalid credentials.";
}
} else {
echo "No user found.";
}
}
?>

<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);
?>

<h1>Welcome to Your Dashboard</h1>


<a href="add_application.php">Add New Application</a>

<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'];

$sql = "INSERT INTO applications (user_id, job_title, company_name, status,


follow_up_date, notes) VALUES ('$user_id', '$job_title', '$company_name',
'$status', '$follow_up_date', '$notes')";

if ($conn->query($sql) === TRUE) {


header("Location: dashboard.php");
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
}
?>

<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'];

$sql = "UPDATE applications SET job_title = '$job_title', company_name =


'$company_name', status = '$status', follow_up_date = '$follow_up_date', notes =
'$notes' WHERE application_id = $application_id";

if ($conn->query($sql) === TRUE) {


header("Location: dashboard.php");
} else {
echo "Error: " . $conn->error;
}
} else {
$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</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:

o Reminder feature to notify users of upcoming deadlines or follow-up dates via


email or on-site alerts.
o Option for users to toggle reminders for specific applications.
7. Application History/Timeline:
o A timeline view showing the history of updates for each application (e.g.,
applied on X date, received interview on Y date).
o Provides users with a log of their interactions for each job application.
ChatGPT said:
ChatGPT
Let's break down the implementation of the features you requested for editing,
deleting applications, search & filtering, notifications & reminders, and
application history/timeline:

4. Edit and Delete Applications


We already have the basics of adding and editing applications, but let's expand on
that and implement deleting applications as well.

4.1 Edit Application


We will use a form that allows users to update details of a job application, such
as status, deadline, and notes.

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).

5.1 Search Functionality


Add a search box to the dashboard page, where users can search for job
applications.

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'] : '';

// SQL query with search


$sql = "SELECT * FROM applications WHERE user_id = $user_id AND (job_title LIKE ?
OR company_name LIKE ? OR status LIKE ?)";
$stmt = $conn->prepare($sql);
$search_term = "%" . $search_query . "%";
$stmt->bind_param("sss", $search_term, $search_term, $search_term);
$stmt->execute();
$result = $stmt->get_result();
?>

<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'] : '';

$sql = "SELECT * FROM applications WHERE user_id = $user_id";


if ($status_filter) {
$sql .= " AND status = ?";
}
$stmt = $conn->prepare($sql);
if ($status_filter) {
$stmt->bind_param("s", $status_filter);
}
$stmt->execute();
$result = $stmt->get_result();
?>
6. Notifications and Reminders
To send reminders for follow-up dates, we'll use a cron job (for server-side
notifications) or JavaScript alerts (for on-site reminders).

6.1 Email Reminders


Use PHP’s mail() function or a service like PHPMailer for email reminders. Here's
an example of sending an email reminder if the follow-up date is nearing:

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();

while ($row = $result->fetch_assoc()) {


$to = $_SESSION['email'];
$subject = "Reminder: Follow-up for " . $row['job_title'] . " at " .
$row['company_name'];
$message = "Don't forget to follow up on your application for " .
$row['job_title'] . " at " . $row['company_name'] . " on " .
$row['follow_up_date'];
mail($to, $subject, $message);
}
6.2 On-Site Alerts Using JavaScript
You can show an alert for the user if the follow-up date is near.

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;

if (timeDifference <= 48 * 60 * 60 * 1000 && timeDifference >= 0) {


alert("Reminder: Follow-up for " + application.job_title + " at " +
application.company_name + " is coming up soon.");
}
});
7. Application History/Timeline
Create a timeline or log of interactions for each application, showing updates like
"applied on X date," "interview scheduled on Y date," etc.

7.1 Timeline of Application Updates


Store changes to an application's status and track them in a new table called
application_history:

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:

Edit and Delete applications.


Search and Filter by job title, company name, or status.
Set up Notifications for reminders of follow-up dates.
Track the History of each application's status changes.
These steps will make your Job Application Tracker highly functional and user-
friendly.

You might also like