PHP ProjectsSoftware Projects

Online Job Finder System in PHP Free Source Code

Online Job Finder System Platform in PHP and MySQL Free Source Code is a website where the any or most users can easily search for jobs for themselves. This projects will give the company a qualified employee for them. Users who need to get employed go to browse jobs page and see all their required gigs available. This page shows the category of employment list like food and restaurant, construction technology, fashion, and design, etc. Eventually, they can see full time and part-time jobs.

Creating an Online Job Finder System Project in PHP involves the use of several components, including a database to store job listings and user information, as well as PHP scripts to handle job posting, searching, and applying. Below is an example of how you can set up a basic job finder system.

Set Up the Project Directory

Create a project directory with the following structure:

job-finder-system/
├── config.php
├── db.sql
├── index.php
├── post-job.php
├── search-jobs.php
├── apply-job.php
├── view-job.php
├── styles.css

Database Configuration

You need to Create a db.sql file to set up the database schema:

CREATE DATABASE job_finder;

USE job_finder;

CREATE TABLE jobs (
    id INT AUTO_INCREMENT PRIMARY KEY,
    title VARCHAR(255) NOT NULL,
    company VARCHAR(255) NOT NULL,
    location VARCHAR(255) NOT NULL,
    description TEXT NOT NULL,
    posted_on TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

CREATE TABLE applications (
    id INT AUTO_INCREMENT PRIMARY KEY,
    job_id INT NOT NULL,
    applicant_name VARCHAR(255) NOT NULL,
    email VARCHAR(255) NOT NULL,
    cover_letter TEXT,
    applied_on TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    FOREIGN KEY (job_id) REFERENCES jobs(id)
);

Database Connection

Create a config.php file to handle the database connection as follows

<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "job_finder";

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

// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}
?>

Post a Job

Create a post-job.php file to handle job postings:

<?php
include 'config.php';

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $title = $_POST['title'];
    $company = $_POST['company'];
    $location = $_POST['location'];
    $description = $_POST['description'];

    $sql = "INSERT INTO jobs (title, company, location, description) VALUES ('$title', '$company', '$location', '$description')";

    if ($conn->query($sql) === TRUE) {
        echo "Job posted successfully!";
    } else {
        echo "Error: " . $sql . "<br>" . $conn->error;
    }
}
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Post Job</title>
    <link rel="stylesheet" href="styles.css">
</head>
<body>
    <h1>Post a Job</h1>
    <form action="post-job.php" method="POST">
        <label for="title">Job Title:</label>
        <input type="text" id="title" name="title" required>
        <label for="company">Company:</label>
        <input type="text" id="company" name="company" required>
        <label for="location">Location:</label>
        <input type="text" id="location" name="location" required>
        <label for="description">Description:</label>
        <textarea id="description" name="description" required></textarea>
        <button type="submit">Post Job</button>
    </form>
</body>
</html>

Search for Jobs

Create a search-jobs.php file to handle job searching and hunting.

<?php
include 'config.php';

$search = $_GET['search'] ?? '';

$sql = "SELECT * FROM jobs WHERE title LIKE '%$search%' OR company LIKE '%$search%' OR location LIKE '%$search%'";
$result = $conn->query($sql);
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Search Jobs</title>
    <link rel="stylesheet" href="styles.css">
</head>
<body>
    <h1>Search Jobs</h1>
    <form action="search-jobs.php" method="GET">
        <input type="text" name="search" placeholder="Search for jobs..." value="<?php echo htmlspecialchars($search); ?>">
        <button type="submit">Search</button>
    </form>
    <h2>Job Listings</h2>
    <?php
    if ($result->num_rows > 0) {
        while($row = $result->fetch_assoc()) {
            echo "<div class='job-listing'>";
            echo "<h3>{$row['title']}</h3>";
            echo "<p><strong>Company:</strong> {$row['company']}</p>";
            echo "<p><strong>Location:</strong> {$row['location']}</p>";
            echo "<p>{$row['description']}</p>";
            echo "<a href='view-job.php?id={$row['id']}'>View Job</a>";
            echo "</div>";
        }
    } else {
        echo "No jobs found.";
    }
    ?>
</body>
</html>

View Job Details

Create a view-job.php file to display job details and allow applications:

<?php
include 'config.php';

$job_id = $_GET['id'];
$sql = "SELECT * FROM jobs WHERE id='$job_id'";
$result = $conn->query($sql);
$job = $result->fetch_assoc();
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>View Job</title>
    <link rel="stylesheet" href="styles.css">
</head>
<body>
    <h1><?php echo $job['title']; ?></h1>
    <p><strong>Company:</strong> <?php echo $job['company']; ?></p>
    <p><strong>Location:</strong> <?php echo $job['location']; ?></p>
    <p><?php echo nl2br($job['description']); ?></p>
    <a href="apply-job.php?id=<?php echo $job['id']; ?>">Apply for this job</a>
</body>
</html>

Apply for a Job

Create an apply-job.php file to handle job applications

<?php
include 'config.php';

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $job_id = $_POST['job_id'];
    $applicant_name = $_POST['applicant_name'];
    $email = $_POST['email'];
    $cover_letter = $_POST['cover_letter'];

    $sql = "INSERT INTO applications (job_id, applicant_name, email, cover_letter) VALUES ('$job_id', '$applicant_name', '$email', '$cover_letter')";

    if ($conn->query($sql) === TRUE) {
        echo "Application submitted successfully!";
    } else {
        echo "Error: " . $sql . "<br>" . $conn->error;
    }
} else {
    $job_id = $_GET['id'];
}
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Apply for Job</title>
    <link rel="stylesheet" href="styles.css">
</head>
<body>
    <h1>Apply for Job</h1>
    <form action="apply-job.php" method="POST">
        <input type="hidden" name="job_id" value="<?php echo $job_id; ?>">
        <label for="applicant_name">Name:</label>
        <input type="text" id="applicant_name" name="applicant_name" required>
        <label for="email">Email:</label>
        <input type="email" id="email" name="email" required>
        <label for="cover_letter">Cover Letter:</label>
        <textarea id="cover_letter" name="cover_letter"></textarea>
        <button type="submit">Apply</button>
    </form>
</body>
</html>

Styling

body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
margin: 0;
padding: 20px;
}

h1, h2 {
text-align: center;
}

form {
display: flex;
flex-direction: column;
max-width: 600px;
margin: 0 auto;
}

label {
margin-top: 10px;
}

input, textarea, button {
padding: 10px;
margin-top: 5px;
}

button {
background-color: #4CAF50;
color: white;
border: none;
cursor: pointer;
}

button:hover {
background-color: #45a049;
}

.job-listing {
background-color: white;
padding: 15px;
margin-top: 15px;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button
/