How to develop Projects (OJP) Using PHP and Mysql IN ONE GLANCE

Rashmi Mishra
0


How to develop Projects (OJP) 

Using PHP and Mysql 

1. Authentication and Login System

  • Login page for:
    • Admin
    • Employer
    • Job Seeker
  • Session management (after login, different dashboards should open based on the role).
  • Forgot Password (optional, later stage).

2. Profile Management

Each user should be able to:

  • View and Update their profile:
    • Admin: Update contact info.
    • Employer: Company profile, logo, description, etc.
    • Job Seeker: Resume, skills, experience, photo, etc.

3. Job Posting Module (Employer Side)

Employers should be able to:

  • Add New Job Post (Job Title, Description, Salary, Location, etc.)
  • Manage (Edit/Delete) their Posted Jobs.
  • See the list of all their posted jobs.

4. Job Browsing and Application (Job Seeker Side)

Job Seekers should be able to:

  • Browse all available job postings.
  • Apply for a job.
  • View their Applied Jobs history.

5. Admin Panel Features

Admin should be able to:

  • Manage all Users (approve/block/delete users).
  • Manage all Employers (approve/block/delete employers).
  • Manage all Job Posts (approve/reject/delete jobs).
  • View Reports (Number of users, number of job posts, applications, etc.).

6. Application Management (Employer Side)

Employers should be able to:

  • View the list of candidates who applied for their job posts.
  • Download Resume/CV.
  • Approve/Reject/Shortlist candidates.

7. Search and Filter System

  • Job seekers can search jobs by keywords, location, salary range, company, etc.
  • Employers can search candidates by skills, experience, etc.

8. Notification or Email System (Optional, Later)

  • Send confirmation emails on registration, job application, etc.

📌 General Structure Suggestion:

  • /admin/ → Admin dashboard
  • /employer/ → Employer dashboard
  • /jobseeker/ → Job seeker dashboard


🔷 Flow Diagram (Simple)

[ Registration / Sign Up ]

           

[ Login (Admin / Employer / Job Seeker) ]

           

[ Role-Based Dashboard ]

     ┌──────────────────────────────────────────┐

                                

[ Admin Panel ] [ Employer Panel ] [ Job Seeker Panel ]

                                

[ Manage Users ]  [ Post Jobs ]    [ Browse Jobs ]

[ Manage Jobs ]   [ View Applicants ] [ Apply for Jobs ]

[ View Reports ]  [ Manage Company Profile ] [ View Applied Jobs ]


🔷 Next Modules Table (Roadmap)

Module

User

Description

1. Login & Dashboard

Admin, Employer, Job Seeker

Role-based login and separate dashboards.

2. Profile Management

All Users

Update name, email, resume, company info, etc.

3. Post Job

Employer

Create and manage job posts.

4. Job Listings

Job Seeker

Browse all available jobs.

5. Apply for Jobs

Job Seeker

Apply to jobs and manage applications.

6. View Applicants

Employer

See who applied for their posted jobs.

7. Manage Users & Jobs

Admin

Approve/block users, approve/reject jobs.

8. Reports (Optional)

Admin

View statistics (total users, jobs, applications).

9. Search & Filter

All Users

Filter/search jobs and candidates easily.

10. Notification/Emails (Optional)

All Users

Send confirmation emails/messages.


🔷 How to Proceed Step-by-Step (Simple Plan)

Step

Task

Step 1

Complete Login System (with role check).

Step 2

Build Basic Dashboards (Admin, Employer, Job Seeker).

Step 3

Develop Profile Update pages.

Step 4

Employer: Create Job Posting module.

Step 5

Job Seeker: Browse Jobs and Apply module.

Step 6

Employer: View Applicants module.

Step 7

Admin: User and Job Management modules.

Step 8

(Optional) Add Search, Filters, and Notifications.


📂 Project Structure

job-portal/

── index.php               # Main entry file (login page maybe)

── config/

   └── db.php               # Database connection file

── assets/

   ── css/                 # All CSS files

      └── style.css

   ── js/                  # JavaScript files

   └── images/              # Uploaded logos, profile pictures, etc.

── includes/

   ── header.php           # Common Header

   ── footer.php           # Common Footer

   └── sidebar.php          # Common Sidebar (role-wise if needed)

── admin/

   ── dashboard.php        # Admin Dashboard

   ── manage_users.php     # View, approve, block users

   ── manage_jobs.php      # View, approve, delete jobs

   ── reports.php          # View reports and statistics

   └── profile.php          # Admin profile management

── employer/

   ── dashboard.php        # Employer Dashboard

   ── post_job.php         # Post a new job

   ── manage_jobs.php      # Manage posted jobs

   ── view_applicants.php  # View applicants for jobs

   └── profile.php          # Employer profile management

── jobseeker/

   ── dashboard.php        # Jobseeker Dashboard

   ── browse_jobs.php      # Browse jobs

   ── apply_job.php        # Apply for a job

   ── applied_jobs.php     # View applied jobs

   └── profile.php          # Jobseeker profile management

── login/

   ── login.php            # Login form

   ── register.php         # Registration form

   └── logout.php           # Logout script

── uploads/

   ── resumes/             # Uploaded resumes of jobseekers

   └── company_logos/       # Uploaded logos of employers

└── README.md                # Project documentation (optional)


🛠️ Explanation:

  • index.php → Landing page or login redirection.
  • config/db.php → Database connection settings.
  • assets/ → All your CSS, JS, and image files neatly stored.
  • includes/ → Common header/footer/sidebar for reusability.
  • admin/, employer/, jobseeker/ → Separate folders for each user's dashboard and features.
  • login/ → Login, Register, and Logout scripts.
  • uploads/ → To store resumes and company logos securely.

📋 Bonus Tips:

  • Always protect folders like /uploads/ using .htaccess (for security).
  • Use sessions to maintain logged-in user data.
  • Separate SQL queries in small functions to avoid repeating the same code everywhere.

CODE


📂 job-portal/

job-portal/

── index.php               # Main entry file (login page maybe)

── config/

   └── db.php               # Database connection file

I'll now write full detailed code for both:
index.php
config/db.php


1. config/db.php

(This file is used to connect to your MySQL Database.)

config/db.php

<?php

// Start session if not already started

if (session_status() == PHP_SESSION_NONE) {

    session_start();

}

 

// Database Configuration

$servername = "localhost";    // Usually localhost

$username = "root";           // Default XAMPP username

$password = "";               // Default XAMPP password (empty)

$dbname = "job_portal";       // Your Database name

 

// Create connection

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

 

// Check connection

if ($conn->connect_error) {

    die("Database Connection Failed: " . $conn->connect_error);

}

?>

Now you can use $conn on any page after including this db.php.


2. index.php

(This will be your main landing page. Usually a small login box.)

We will design it like a simple "Welcome to Job Portal" + "Login" page.


index.php

<?php

// Redirect if already logged in

session_start();

if (isset($_SESSION['role'])) {

    if ($_SESSION['role'] == 'admin') {

        header('Location: /admin/dashboard.php');

    } elseif ($_SESSION['role'] == 'employer') {

        header('Location: /employer/dashboard.php');

    } elseif ($_SESSION['role'] == 'jobseeker') {

        header('Location: /jobseeker/dashboard.php');

    }

    exit();

}

?>

 

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <title>Online Job Portal</title>

 

    <!-- Bootstrap CSS -->

    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">

 

    <style>

        body {

            background: linear-gradient(to right, #6a11cb, #2575fc);

            min-height: 100vh;

            display: flex;

            align-items: center;

            justify-content: center;

        }

        .login-box {

            background: #fff;

            padding: 30px;

            border-radius: 10px;

            width: 400px;

        }

    </style>

</head>

<body>

 

<div class="login-box">

    <h2 class="text-center mb-4">Welcome to Job Portal</h2>

 

    <form action="/login/login.php" method="POST">

        <div class="mb-3">

            <label for="email" class="form-label">Email address</label>

            <input type="email" class="form-control" id="email" name="email" required autofocus>

        </div>

 

        <div class="mb-3">

            <label for="password" class="form-label">Password</label>

            <input type="password" class="form-control" id="password" name="password" required>

        </div>

 

        <button type="submit" class="btn btn-primary w-100">Login</button>

 

        <p class="mt-3 text-center">

            Don't have an account? <a href="/login/register.php">Register here</a>

        </p>

    </form>

</div>

 

<!-- Bootstrap JS Bundle -->

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>

 

</body>

</html>


Now Done:

File

Purpose

index.php

First entry page (Login + Welcome)

config/db.php

Common database connection for whole project


🔥 Important Notes:

  • After login, you should redirect users to their dashboards based on their role.
  • db.php must be included in every PHP file where you want to interact with the database.

include('../config/db.php');


🛠 What's Next after this?

If you want, I can also help you organize:

  • /assets/ (CSS, JS, images)
  • /uploads/ (for resumes, company logos)
  • /templates/ (optional if you want beautiful email templates)

 

📂 includes/

Contains files that are common across all pages: header, footer, sidebar.


1. header.php

This file will be included at the top of every page. It usually contains:

  • The opening HTML tags
  • Meta tags
  • Bootstrap/stylesheet links
  • Navigation bar (if any)

includes/header.php

<?php

// Start session if not started

if (session_status() == PHP_SESSION_NONE) {

    session_start();

}

?>

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Online Job Portal</title>

   

    <!-- Bootstrap CSS -->

    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">

 

    <!-- Custom CSS -->

    <link rel="stylesheet" href="/assets/css/style.css">

</head>

<body>

 

<!-- Navigation Bar -->

<nav class="navbar navbar-expand-lg navbar-dark bg-dark">

  <div class="container-fluid">

    <a class="navbar-brand" href="#">Job Portal</a>

    <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">

      <span class="navbar-toggler-icon"></span>

    </button>

   

    <div class="collapse navbar-collapse" id="navbarNav">

      <ul class="navbar-nav ms-auto">

        <?php if(isset($_SESSION['role'])): ?>

          <li class="nav-item">

            <a class="nav-link" href="/login/logout.php">Logout</a>

          </li>

        <?php else: ?>

          <li class="nav-item">

            <a class="nav-link" href="/login/login.php">Login</a>

          </li>

        <?php endif; ?>

      </ul>

    </div>

  </div>

</nav>

 

<div class="container mt-4">


2. footer.php

This file will be included at the bottom of every page. It usually contains:

  • Closing the HTML tags
  • Footer design
  • JavaScript files like Bootstrap.js

includes/footer.php

</div> <!-- End Container -->

 

<!-- Footer -->

<footer class="bg-dark text-white text-center py-3 mt-5">

    <p class="mb-0">&copy; <?php echo date("Y"); ?> Online Job Portal. All rights reserved.</p>

</footer>

 

<!-- Bootstrap JS Bundle -->

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>

 

<!-- Custom JS -->

<script src="/assets/js/script.js"></script>

 

</body>

</html>


3. sidebar.php

This will create a sidebar for dashboard pages, based on role (admin, employer, jobseeker).

includes/sidebar.php

<?php

if (session_status() == PHP_SESSION_NONE) {

    session_start();

}

 

if (!isset($_SESSION['role'])) {

    // Redirect if not logged in

    header("Location: /login/login.php");

    exit();

}

 

$role = $_SESSION['role'];

?>

 

<!-- Sidebar -->

<div class="d-flex">

    <nav class="flex-column bg-light p-3" style="min-width: 200px; height: 100vh;">

        <h5 class="text-center"><?php echo ucfirst($role); ?> Panel</h5>

        <ul class="nav flex-column">

            <?php if ($role == 'admin'): ?>

                <li class="nav-item"><a class="nav-link" href="/admin/dashboard.php">Dashboard</a></li>

                <li class="nav-item"><a class="nav-link" href="/admin/manage_users.php">Manage Users</a></li>

                <li class="nav-item"><a class="nav-link" href="/admin/manage_jobs.php">Manage Jobs</a></li>

                <li class="nav-item"><a class="nav-link" href="/admin/reports.php">Reports</a></li>

                <li class="nav-item"><a class="nav-link" href="/admin/profile.php">Profile</a></li>

 

            <?php elseif ($role == 'employer'): ?>

                <li class="nav-item"><a class="nav-link" href="/employer/dashboard.php">Dashboard</a></li>

                <li class="nav-item"><a class="nav-link" href="/employer/post_job.php">Post Job</a></li>

                <li class="nav-item"><a class="nav-link" href="/employer/manage_jobs.php">Manage Jobs</a></li>

                <li class="nav-item"><a class="nav-link" href="/employer/view_applicants.php">View Applicants</a></li>

                <li class="nav-item"><a class="nav-link" href="/employer/profile.php">Profile</a></li>

 

            <?php elseif ($role == 'jobseeker'): ?>

                <li class="nav-item"><a class="nav-link" href="/jobseeker/dashboard.php">Dashboard</a></li>

                <li class="nav-item"><a class="nav-link" href="/jobseeker/browse_jobs.php">Browse Jobs</a></li>

                <li class="nav-item"><a class="nav-link" href="/jobseeker/applied_jobs.php">Applied Jobs</a></li>

                <li class="nav-item"><a class="nav-link" href="/jobseeker/profile.php">Profile</a></li>

 

            <?php endif; ?>

        </ul>

    </nav>

 

    <!-- Main Content -->

    <div class="flex-grow-1 p-3">


🧩 Important:

  • Every dashboard page (like admin/dashboard.php, employer/dashboard.php, etc.) should start with:

<?php include('../includes/header.php'); ?>

<?php include('../includes/sidebar.php'); ?>

  • And end with:

<?php include('../includes/footer.php'); ?>

That way your pages will automatically have header, sidebar, and footer!


Done: Now your includes/ folder is fully ready!


1️ admin/dashboard.php – Admin Dashboard

<?php

session_start();

require_once('../config/db.php');

 

// Check if admin is logged in

if (!isset($_SESSION['admin_id'])) {

    header('Location: ../login/login.php');

    exit();

}

?>

 

<?php include('../includes/header.php'); ?>

<h1>Admin Dashboard</h1>

 

<div class="row">

    <div class="col-md-4">

        <div class="card p-3">

            <?php

            $userCount = mysqli_fetch_assoc(mysqli_query($conn, "SELECT COUNT(*) as total FROM users"));

            ?>

            <h2>Total Users: <?php echo $userCount['total']; ?></h2>

        </div>

    </div>

    <div class="col-md-4">

        <div class="card p-3">

            <?php

            $jobCount = mysqli_fetch_assoc(mysqli_query($conn, "SELECT COUNT(*) as total FROM jobs"));

            ?>

            <h2>Total Jobs: <?php echo $jobCount['total']; ?></h2>

        </div>

    </div>

</div>

 

<?php include('../includes/footer.php'); ?>


2️ admin/manage_users.php – Manage Users

<?php

session_start();

require_once('../config/db.php');

 

// Check admin login

if (!isset($_SESSION['admin_id'])) {

    header('Location: ../login/login.php');

    exit();

}

 

// Approve or block users

if (isset($_GET['action']) && isset($_GET['id'])) {

    $id = intval($_GET['id']);

    $action = $_GET['action'];

    if ($action == 'approve') {

        mysqli_query($conn, "UPDATE users SET status='approved' WHERE id=$id");

    } elseif ($action == 'block') {

        mysqli_query($conn, "UPDATE users SET status='blocked' WHERE id=$id");

    }

    header('Location: manage_users.php');

}

?>

 

<?php include('../includes/header.php'); ?>

<h1>Manage Users</h1>

 

<table class="table table-bordered">

    <tr>

        <th>#</th>

        <th>Name</th>

        <th>Email</th>

        <th>Status</th>

        <th>Action</th>

    </tr>

    <?php

    $query = mysqli_query($conn, "SELECT * FROM users");

    while ($row = mysqli_fetch_assoc($query)) {

        echo "<tr>

                <td>".$row['id']."</td>

                <td>".$row['name']."</td>

                <td>".$row['email']."</td>

                <td>".$row['status']."</td>

                <td>

                    <a href='manage_users.php?action=approve&id=".$row['id']."' class='btn btn-success btn-sm'>Approve</a>

                    <a href='manage_users.php?action=block&id=".$row['id']."' class='btn btn-danger btn-sm'>Block</a>

                </td>

            </tr>";

    }

    ?>

</table>

 

<?php include('../includes/footer.php'); ?>


3️ admin/manage_jobs.php – Manage Jobs

<?php

session_start();

require_once('../config/db.php');

 

// Check admin login

if (!isset($_SESSION['admin_id'])) {

    header('Location: ../login/login.php');

    exit();

}

 

// Approve or delete jobs

if (isset($_GET['action']) && isset($_GET['id'])) {

    $id = intval($_GET['id']);

    $action = $_GET['action'];

    if ($action == 'approve') {

        mysqli_query($conn, "UPDATE jobs SET status='approved' WHERE id=$id");

    } elseif ($action == 'delete') {

        mysqli_query($conn, "DELETE FROM jobs WHERE id=$id");

    }

    header('Location: manage_jobs.php');

}

?>

 

<?php include('../includes/header.php'); ?>

<h1>Manage Jobs</h1>

 

<table class="table table-bordered">

    <tr>

        <th>#</th>

        <th>Job Title</th>

        <th>Company</th>

        <th>Status</th>

        <th>Action</th>

    </tr>

    <?php

    $query = mysqli_query($conn, "SELECT * FROM jobs");

    while ($row = mysqli_fetch_assoc($query)) {

        echo "<tr>

                <td>".$row['id']."</td>

                <td>".$row['title']."</td>

                <td>".$row['company']."</td>

                <td>".$row['status']."</td>

                <td>

                    <a href='manage_jobs.php?action=approve&id=".$row['id']."' class='btn btn-success btn-sm'>Approve</a>

                    <a href='manage_jobs.php?action=delete&id=".$row['id']."' class='btn btn-danger btn-sm'>Delete</a>

                </td>

            </tr>";

    }

    ?>

</table>

 

<?php include('../includes/footer.php'); ?>


4️ admin/reports.php – View Reports

<?php

session_start();

require_once('../config/db.php');

 

// Check admin login

if (!isset($_SESSION['admin_id'])) {

    header('Location: ../login/login.php');

    exit();

}

?>

 

<?php include('../includes/header.php'); ?>

<h1>Reports and Statistics</h1>

 

<div class="row">

    <div class="col-md-4">

        <div class="card p-3">

            <?php

            $users = mysqli_fetch_assoc(mysqli_query($conn, "SELECT COUNT(*) as total FROM users"));

            ?>

            <h3>Total Registered Users: <?php echo $users['total']; ?></h3>

        </div>

    </div>

 

    <div class="col-md-4">

        <div class="card p-3">

            <?php

            $jobs = mysqli_fetch_assoc(mysqli_query($conn, "SELECT COUNT(*) as total FROM jobs"));

            ?>

            <h3>Total Jobs Posted: <?php echo $jobs['total']; ?></h3>

        </div>

    </div>

 

    <div class="col-md-4">

        <div class="card p-3">

            <?php

            $applications = mysqli_fetch_assoc(mysqli_query($conn, "SELECT COUNT(*) as total FROM applications"));

            ?>

            <h3>Total Job Applications: <?php echo $applications['total']; ?></h3>

        </div>

    </div>

</div>

 

<?php include('../includes/footer.php'); ?>


5️ admin/profile.php – Admin Profile Management

<?php

session_start();

require_once('../config/db.php');

 

// Check admin login

if (!isset($_SESSION['admin_id'])) {

    header('Location: ../login/login.php');

    exit();

}

 

$admin_id = $_SESSION['admin_id'];

 

// Update profile

if (isset($_POST['update'])) {

    $name = mysqli_real_escape_string($conn, $_POST['name']);

    $email = mysqli_real_escape_string($conn, $_POST['email']);

   

    mysqli_query($conn, "UPDATE admins SET name='$name', email='$email' WHERE id=$admin_id");

    $success = "Profile updated successfully!";

}

 

// Fetch admin info

$admin = mysqli_fetch_assoc(mysqli_query($conn, "SELECT * FROM admins WHERE id=$admin_id"));

?>

 

<?php include('../includes/header.php'); ?>

<h1>My Profile</h1>

 

<?php if(isset($success)) { echo "<div class='alert alert-success'>$success</div>"; } ?>

 

<form method="post" action="">

    <div class="form-group">

        <label>Name:</label>

        <input type="text" name="name" value="<?php echo $admin['name']; ?>" class="form-control" required>

    </div>

    <div class="form-group">

        <label>Email:</label>

        <input type="email" name="email" value="<?php echo $admin['email']; ?>" class="form-control" required>

    </div>

    <br>

    <button type="submit" name="update" class="btn btn-primary">Update Profile</button>

</form>

 

<?php include('../includes/footer.php'); ?>


🛑 Important:

  • Make sure your database has tables like:
    • users (id, name, email, password, status)
    • jobs (id, title, company, description, status)
    • applications (id, job_id, user_id, date)
    • admins (id, name, email, password)


1️ employer/dashboard.php – Employer Dashboard

<?php

session_start();

require_once('../config/db.php');

 

// Check if employer is logged in

if (!isset($_SESSION['employer_id'])) {

    header('Location: ../login/login.php');

    exit();

}

 

$employer_id = $_SESSION['employer_id'];

?>

 

<?php include('../includes/header.php'); ?>

<h1>Employer Dashboard</h1>

 

<div class="row">

    <div class="col-md-6">

        <div class="card p-3">

            <?php

            $jobCount = mysqli_fetch_assoc(mysqli_query($conn, "SELECT COUNT(*) as total FROM jobs WHERE employer_id=$employer_id"));

            ?>

            <h3>Total Jobs Posted: <?php echo $jobCount['total']; ?></h3>

        </div>

    </div>

    <div class="col-md-6">

        <div class="card p-3">

            <?php

            $applicantCount = mysqli_fetch_assoc(mysqli_query($conn, "SELECT COUNT(*) as total FROM applications

                INNER JOIN jobs ON applications.job_id = jobs.id

                WHERE jobs.employer_id=$employer_id"));

            ?>

            <h3>Total Applications Received: <?php echo $applicantCount['total']; ?></h3>

        </div>

    </div>

</div>

 

<?php include('../includes/footer.php'); ?>


2️ employer/post_job.php – Post a New Job

<?php

session_start();

require_once('../config/db.php');

 

if (!isset($_SESSION['employer_id'])) {

    header('Location: ../login/login.php');

    exit();

}

 

$employer_id = $_SESSION['employer_id'];

 

if (isset($_POST['submit'])) {

    $title = mysqli_real_escape_string($conn, $_POST['title']);

    $description = mysqli_real_escape_string($conn, $_POST['description']);

    $location = mysqli_real_escape_string($conn, $_POST['location']);

   

    mysqli_query($conn, "INSERT INTO jobs (employer_id, title, description, location, status) VALUES ($employer_id, '$title', '$description', '$location', 'pending')");

    $success = "Job Posted Successfully! Waiting for Admin Approval.";

}

?>

 

<?php include('../includes/header.php'); ?>

<h1>Post New Job</h1>

 

<?php if(isset($success)) { echo "<div class='alert alert-success'>$success</div>"; } ?>

 

<form method="POST" action="">

    <div class="form-group">

        <label>Job Title</label>

        <input type="text" name="title" class="form-control" required>

    </div>

    <div class="form-group">

        <label>Job Description</label>

        <textarea name="description" class="form-control" required></textarea>

    </div>

    <div class="form-group">

        <label>Location</label>

        <input type="text" name="location" class="form-control" required>

    </div>

    <br>

    <button type="submit" name="submit" class="btn btn-primary">Post Job</button>

</form>

 

<?php include('../includes/footer.php'); ?>


3️ employer/manage_jobs.php – Manage Posted Jobs

<?php

session_start();

require_once('../config/db.php');

 

if (!isset($_SESSION['employer_id'])) {

    header('Location: ../login/login.php');

    exit();

}

 

$employer_id = $_SESSION['employer_id'];

 

// Delete Job

if (isset($_GET['action']) && $_GET['action'] == 'delete' && isset($_GET['id'])) {

    $id = intval($_GET['id']);

    mysqli_query($conn, "DELETE FROM jobs WHERE id=$id AND employer_id=$employer_id");

    header('Location: manage_jobs.php');

}

?>

 

<?php include('../includes/header.php'); ?>

<h1>Manage Your Jobs</h1>

 

<table class="table table-bordered">

    <tr>

        <th>#</th>

        <th>Title</th>

        <th>Location</th>

        <th>Status</th>

        <th>Action</th>

    </tr>

    <?php

    $query = mysqli_query($conn, "SELECT * FROM jobs WHERE employer_id=$employer_id");

    while ($row = mysqli_fetch_assoc($query)) {

        echo "<tr>

                <td>".$row['id']."</td>

                <td>".$row['title']."</td>

                <td>".$row['location']."</td>

                <td>".$row['status']."</td>

                <td>

                    <a href='manage_jobs.php?action=delete&id=".$row['id']."' class='btn btn-danger btn-sm' onclick=\"return confirm('Are you sure?')\">Delete</a>

                </td>

            </tr>";

    }

    ?>

</table>

 

<?php include('../includes/footer.php'); ?>


4️ employer/view_applicants.php – View Applicants for Jobs

<?php

session_start();

require_once('../config/db.php');

 

if (!isset($_SESSION['employer_id'])) {

    header('Location: ../login/login.php');

    exit();

}

 

$employer_id = $_SESSION['employer_id'];

?>

 

<?php include('../includes/header.php'); ?>

<h1>Applicants for Your Jobs</h1>

 

<table class="table table-bordered">

    <tr>

        <th>Job Title</th>

        <th>Applicant Name</th>

        <th>Applicant Email</th>

        <th>Applied On</th>

    </tr>

    <?php

    $query = mysqli_query($conn, "SELECT applications.*, users.name as user_name, users.email as user_email, jobs.title as job_title

                                  FROM applications

                                  INNER JOIN users ON applications.user_id = users.id

                                  INNER JOIN jobs ON applications.job_id = jobs.id

                                  WHERE jobs.employer_id = $employer_id");

    while ($row = mysqli_fetch_assoc($query)) {

        echo "<tr>

                <td>".$row['job_title']."</td>

                <td>".$row['user_name']."</td>

                <td>".$row['user_email']."</td>

                <td>".$row['created_at']."</td>

            </tr>";

    }

    ?>

</table>

 

<?php include('../includes/footer.php'); ?>


5️ employer/profile.php – Employer Profile Management

<?php

session_start();

require_once('../config/db.php');

 

if (!isset($_SESSION['employer_id'])) {

    header('Location: ../login/login.php');

    exit();

}

 

$employer_id = $_SESSION['employer_id'];

 

// Update profile

if (isset($_POST['update'])) {

    $name = mysqli_real_escape_string($conn, $_POST['name']);

    $email = mysqli_real_escape_string($conn, $_POST['email']);

    $company = mysqli_real_escape_string($conn, $_POST['company']);

   

    mysqli_query($conn, "UPDATE employers SET name='$name', email='$email', company_name='$company' WHERE id=$employer_id");

    $success = "Profile updated successfully!";

}

 

// Fetch employer info

$employer = mysqli_fetch_assoc(mysqli_query($conn, "SELECT * FROM employers WHERE id=$employer_id"));

?>

 

<?php include('../includes/header.php'); ?>

<h1>My Profile</h1>

 

<?php if(isset($success)) { echo "<div class='alert alert-success'>$success</div>"; } ?>

 

<form method="post" action="">

    <div class="form-group">

        <label>Name:</label>

        <input type="text" name="name" value="<?php echo $employer['name']; ?>" class="form-control" required>

    </div>

    <div class="form-group">

        <label>Email:</label>

        <input type="email" name="email" value="<?php echo $employer['email']; ?>" class="form-control" required>

    </div>

    <div class="form-group">

        <label>Company Name:</label>

        <input type="text" name="company" value="<?php echo $employer['company_name']; ?>" class="form-control" required>

    </div>

    <br>

    <button type="submit" name="update" class="btn btn-primary">Update Profile</button>

</form>

 

<?php include('../includes/footer.php'); ?>



🛑 Important:

  • Your database must have jobs, applications, and employers tables.
  • Employer id must be stored in session after login:

$_SESSION['employer_id'] = $row['id'];

  • Basic includes like header.php, footer.php, and db.php must be already present.

 

1️ jobseeker/dashboard.php – Jobseeker Dashboard

php

CopyEdit

<?php

session_start();

require_once('../config/db.php');

 

// Check if jobseeker is logged in

if (!isset($_SESSION['jobseeker_id'])) {

    header('Location: ../login/login.php');

    exit();

}

 

$jobseeker_id = $_SESSION['jobseeker_id'];

?>

 

<?php include('../includes/header.php'); ?>

<h1>Jobseeker Dashboard</h1>

 

<div class="row">

    <div class="col-md-6">

        <div class="card p-3">

            <?php

            $appliedCount = mysqli_fetch_assoc(mysqli_query($conn, "SELECT COUNT(*) as total FROM applications WHERE user_id=$jobseeker_id"));

            ?>

            <h3>Total Jobs Applied: <?php echo $appliedCount['total']; ?></h3>

        </div>

    </div>

    <div class="col-md-6">

        <div class="card p-3">

            <?php

            $availableJobs = mysqli_fetch_assoc(mysqli_query($conn, "SELECT COUNT(*) as total FROM jobs WHERE status='approved'"));

            ?>

            <h3>Available Jobs: <?php echo $availableJobs['total']; ?></h3>

        </div>

    </div>

</div>

 

<?php include('../includes/footer.php'); ?>


2️ jobseeker/browse_jobs.php – Browse Jobs

<?php

session_start();

require_once('../config/db.php');

 

if (!isset($_SESSION['jobseeker_id'])) {

    header('Location: ../login/login.php');

    exit();

}

?>

 

<?php include('../includes/header.php'); ?>

<h1>Browse Jobs</h1>

 

<table class="table table-bordered">

    <tr>

        <th>Title</th>

        <th>Location</th>

        <th>Description</th>

        <th>Action</th>

    </tr>

    <?php

    $query = mysqli_query($conn, "SELECT * FROM jobs WHERE status='approved'");

    while ($row = mysqli_fetch_assoc($query)) {

        echo "<tr>

                <td>".$row['title']."</td>

                <td>".$row['location']."</td>

                <td>".substr($row['description'], 0, 50)."...</td>

                <td>

                    <a href='apply_job.php?job_id=".$row['id']."' class='btn btn-success btn-sm'>Apply</a>

                </td>

            </tr>";

    }

    ?>

</table>

 

<?php include('../includes/footer.php'); ?>


3️ jobseeker/apply_job.php – Apply for a Job

<?php

session_start();

require_once('../config/db.php');

 

if (!isset($_SESSION['jobseeker_id'])) {

    header('Location: ../login/login.php');

    exit();

}

 

$jobseeker_id = $_SESSION['jobseeker_id'];

 

if (isset($_GET['job_id'])) {

    $job_id = intval($_GET['job_id']);

 

    // Check if already applied

    $check = mysqli_query($conn, "SELECT * FROM applications WHERE job_id=$job_id AND user_id=$jobseeker_id");

    if (mysqli_num_rows($check) > 0) {

        $message = "You have already applied for this job.";

    } else {

        mysqli_query($conn, "INSERT INTO applications (job_id, user_id, created_at) VALUES ($job_id, $jobseeker_id, NOW())");

        $message = "Successfully Applied!";

    }

} else {

    header('Location: browse_jobs.php');

}

?>

 

<?php include('../includes/header.php'); ?>

 

<h1>Apply for Job</h1>

 

<?php if(isset($message)) { echo "<div class='alert alert-info'>$message</div>"; } ?>

 

<a href="browse_jobs.php" class="btn btn-primary">Back to Jobs</a>

 

<?php include('../includes/footer.php'); ?>


4️ jobseeker/applied_jobs.php – View Applied Jobs

<?php

session_start();

require_once('../config/db.php');

 

if (!isset($_SESSION['jobseeker_id'])) {

    header('Location: ../login/login.php');

    exit();

}

 

$jobseeker_id = $_SESSION['jobseeker_id'];

?>

 

<?php include('../includes/header.php'); ?>

<h1>My Applied Jobs</h1>

 

<table class="table table-bordered">

    <tr>

        <th>Job Title</th>

        <th>Location</th>

        <th>Applied On</th>

    </tr>

    <?php

    $query = mysqli_query($conn, "SELECT applications.created_at, jobs.title, jobs.location

                                  FROM applications

                                  INNER JOIN jobs ON applications.job_id = jobs.id

                                  WHERE applications.user_id = $jobseeker_id");

    while ($row = mysqli_fetch_assoc($query)) {

        echo "<tr>

                <td>".$row['title']."</td>

                <td>".$row['location']."</td>

                <td>".$row['created_at']."</td>

            </tr>";

    }

    ?>

</table>

 

<?php include('../includes/footer.php'); ?>


5️ jobseeker/profile.php – Jobseeker Profile Management

<?php

session_start();

require_once('../config/db.php');

 

if (!isset($_SESSION['jobseeker_id'])) {

    header('Location: ../login/login.php');

    exit();

}

 

$jobseeker_id = $_SESSION['jobseeker_id'];

 

// Update profile

if (isset($_POST['update'])) {

    $name = mysqli_real_escape_string($conn, $_POST['name']);

    $email = mysqli_real_escape_string($conn, $_POST['email']);

   

    mysqli_query($conn, "UPDATE users SET name='$name', email='$email' WHERE id=$jobseeker_id");

    $success = "Profile updated successfully!";

}

 

// Fetch jobseeker info

$user = mysqli_fetch_assoc(mysqli_query($conn, "SELECT * FROM users WHERE id=$jobseeker_id"));

?>

 

<?php include('../includes/header.php'); ?>

<h1>My Profile</h1>

 

<?php if(isset($success)) { echo "<div class='alert alert-success'>$success</div>"; } ?>

 

<form method="post" action="">

    <div class="form-group">

        <label>Name:</label>

        <input type="text" name="name" value="<?php echo $user['name']; ?>" class="form-control" required>

    </div>

    <div class="form-group">

        <label>Email:</label>

        <input type="email" name="email" value="<?php echo $user['email']; ?>" class="form-control" required>

    </div>

    <br>

    <button type="submit" name="update" class="btn btn-primary">Update Profile</button>

</form>

 

<?php include('../includes/footer.php'); ?>


📦 Summary:

Jobseeker dashboard
Browse all approved jobs
Apply for a job (only once)
View all applied jobs
Update profile info


Tips:

  • users table should store jobseekers.
  • jobs table should store job listings (status = approved by admin).
  • applications table should have job_id, user_id, and created_at.


1️ login/login.php – Login Form

<?php

session_start();

require_once('../config/db.php'); // database connection

 

if (isset($_POST['login'])) {

    $email = mysqli_real_escape_string($conn, $_POST['email']);

    $password = md5($_POST['password']); // encrypt password (same as register)

 

    $query = mysqli_query($conn, "SELECT * FROM users WHERE email='$email' AND password='$password'");

 

    if (mysqli_num_rows($query) == 1) {

        $user = mysqli_fetch_assoc($query);

 

        // Set session based on role

        $_SESSION['user_id'] = $user['id'];

        $_SESSION['user_role'] = $user['role'];

 

        if ($user['role'] == 'admin') {

            $_SESSION['admin_id'] = $user['id'];

            header('Location: ../admin/dashboard.php');

        } elseif ($user['role'] == 'employer') {

            $_SESSION['employer_id'] = $user['id'];

            header('Location: ../employer/dashboard.php');

        } elseif ($user['role'] == 'jobseeker') {

            $_SESSION['jobseeker_id'] = $user['id'];

            header('Location: ../jobseeker/dashboard.php');

        }

        exit();

    } else {

        $error = "Invalid Email or Password!";

    }

}

?>

 

<?php include('../includes/header.php'); ?>

 

<h2>Login</h2>

 

<?php if(isset($error)) { echo "<div class='alert alert-danger'>$error</div>"; } ?>

 

<form method="post" action="">

    <div class="form-group">

        <label>Email:</label>

        <input type="email" name="email" class="form-control" required>

    </div>

 

    <div class="form-group">

        <label>Password:</label>

        <input type="password" name="password" class="form-control" required>

    </div>

   

    <br>

    <button type="submit" name="login" class="btn btn-primary">Login</button>

</form>

 

<p>Don't have an account? <a href="register.php">Register Here</a></p>

 

<?php include('../includes/footer.php'); ?>


2️ login/register.php – Registration Form

<?php

session_start();

require_once('../config/db.php'); // database connection

 

if (isset($_POST['register'])) {

    $name = mysqli_real_escape_string($conn, $_POST['name']);

    $email = mysqli_real_escape_string($conn, $_POST['email']);

    $password = md5($_POST['password']); // encrypt password

    $role = mysqli_real_escape_string($conn, $_POST['role']); // jobseeker or employer

 

    // Check if email already exists

    $check = mysqli_query($conn, "SELECT * FROM users WHERE email='$email'");

    if (mysqli_num_rows($check) > 0) {

        $error = "Email already registered!";

    } else {

        mysqli_query($conn, "INSERT INTO users (name, email, password, role, created_at) VALUES ('$name', '$email', '$password', '$role', NOW())");

        $success = "Registration successful! You can now login.";

    }

}

?>

 

<?php include('../includes/header.php'); ?>

 

<h2>Register</h2>

 

<?php if(isset($error)) { echo "<div class='alert alert-danger'>$error</div>"; } ?>

<?php if(isset($success)) { echo "<div class='alert alert-success'>$success</div>"; } ?>

 

<form method="post" action="">

    <div class="form-group">

        <label>Name:</label>

        <input type="text" name="name" class="form-control" required>

    </div>

 

    <div class="form-group">

        <label>Email:</label>

        <input type="email" name="email" class="form-control" required>

    </div>

 

    <div class="form-group">

        <label>Password:</label>

        <input type="password" name="password" class="form-control" required>

    </div>

 

    <div class="form-group">

        <label>Register As:</label>

        <select name="role" class="form-control" required>

            <option value="jobseeker">Jobseeker</option>

            <option value="employer">Employer</option>

        </select>

    </div>

 

    <br>

    <button type="submit" name="register" class="btn btn-primary">Register</button>

</form>

 

<p>Already have an account? <a href="login.php">Login Here</a></p>

 

<?php include('../includes/footer.php'); ?>


3️ login/logout.php – Logout Script

<?php

session_start();

session_unset();

session_destroy();

 

header('Location: login.php');

exit();

?>


📦 Folder Structure Summary

login/

── login.php         # Login Page

── register.php      # Registration Page

└── logout.php        # Destroys Session and Logs Out


📢 Important Things:

  • Passwords are encrypted using md5() ( simple, but later better use bcrypt for better security).
  • Sessions used: admin_id, employer_id, jobseeker_id.
  • You must already have db.php for database connection.
  • users table must have fields:
    id, name, email, password, role, created_at

🛠 Bonus: SQL table for users

CREATE TABLE users (

    id INT AUTO_INCREMENT PRIMARY KEY,

    name VARCHAR(255) NOT NULL,

    email VARCHAR(255) UNIQUE NOT NULL,

    password VARCHAR(255) NOT NULL,

    role ENUM('admin','employer','jobseeker') NOT NULL,

    created_at DATETIME DEFAULT CURRENT_TIMESTAMP

);



📄 README.md

# 🧑‍💼 Online Job Portal System

 

This is a simple PHP-MySQL based **Online Job Portal** where:

- **Admins** manage users and jobs.

- **Employers** post and manage jobs.

- **Jobseekers** browse and apply for jobs.

 

User-friendly, beginner-level project 

Well-structured folder organization 

Easy to extend or customize!

 

---

 

## 📂 Project Structure

 

── admin/ │ ── dashboard.php │ ── manage_users.php │ ── manage_jobs.php │ ── reports.php │ └── profile.php ── employer/ │ ── dashboard.php │ ── post_job.php │ ── manage_jobs.php │ ── view_applicants.php │ └── profile.php ── jobseeker/ │ ── dashboard.php │ ── browse_jobs.php │ ── apply_job.php │ ── applied_jobs.php │ └── profile.php ── login/ │ ── login.php │ ── register.php │ └── logout.php ── config/ │ └── db.php # Database connection ── includes/ │ ── header.php │ └── footer.php ── assets/ │ ── css/ │ └── js/ └── README.md

yaml

CopyEdit

 

---

 

## ⚙️ Requirements

 

- PHP 7.4+ or PHP 8+

- MySQL Database

- Apache Server (Use XAMPP, WAMP, or LAMP)

 

---

 

## 📥 Installation Steps

 

1. **Clone or Download** this repository to your server root (`htdocs` for XAMPP).

2. **Create Database** in phpMyAdmin.

3. **Import SQL file** (`database.sql`) provided in the project (or create manually).

4. **Update Database Config**:

   - Edit `config/db.php` and set your DB username, password, database name.

5. **Run Project**:

   - Open browser: `http://localhost/your_project_folder/login/login.php`

 

---

 

## 👥 User Roles

 

- **Admin**:

  - Manage all users

  - Approve/Block users

  - Approve/Delete jobs

  - View system reports

 

- **Employer**:

  - Post new job vacancies

  - Manage their posted jobs

  - View applicants for jobs

 

- **Jobseeker**:

  - Browse available jobs

  - Apply for jobs

  - View status of applications

 

---

 

## 🛡️ Security

 

- Passwords are **encrypted** using `md5()`.

- **Session-based** authentication for all roles.

- Unauthorized access is restricted.

 

> ⚠️ Note: For production, use **bcrypt** instead of `md5()` for stronger password hashing.

 

---

 

## Features to Improve Later

 

- Add Email Verification during registration

- Add Forgot Password feature

- Use AJAX for smoother operations

- Add Job Categories, Location Filters

- Improve Admin Reporting with Charts

 

---

 

## 🤝 Support

 

If you find any issues, feel free to raise them or improve the project!

 

---

 

## 📢 Important Note

 

This project is designed for **educational/demo** purposes. 

Not recommended for direct production use without adding more security features.

 

---


📌 Quick Points:

  • I used simple ✏️ Markdown syntax: headers (#), lists (-), and code blocks (```) .
  • I kept it clean and beginner-friendly.
  • You can directly copy-paste this into your README.md file.

Your Online Job Portal System is now fully structured!



Post a Comment

0Comments

Post a Comment (0)