0% found this document useful (0 votes)
40 views69 pages

Academic Staff

An academic staff system
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views69 pages

Academic Staff

An academic staff system
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 69

ACADEMIC STAFF PROMOTION MANAGEMENT SYSTEM

academic_promotion_system/

├── index.php (Homepage)

├── add_staff.php (Add academic staff)

├── view_staff.php (View all academic staff)

├── check_promotion.php (Check promotion eligibility)

├── db.php (Database connection)

└── css/

└── style.css (Styling)

CREATE DATABASE academic_promotion;

USE academic_promotion;

CREATE TABLE staff (

id INT AUTO_INCREMENT PRIMARY KEY,

name VARCHAR(100) NOT NULL,

position VARCHAR(50) NOT NULL,

department VARCHAR(100) NOT NULL,

hire_date DATE NOT NULL,

publications INT NOT NULL,

teaching_years INT NOT NULL,

performance_score FLOAT NOT NULL


);

db.php

<?php

$host = "localhost";

$username = "root"; // Replace with your MySQL username

$password = ""; // Replace with your MySQL password

$dbname = "academic_promotion";

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

if ($conn->connect_error) {

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

?>

Index.php

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

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

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


<title>Academic Promotion Management</title>

</head>

<body>

<h1>Academic Staff Promotion Management System</h1>

<nav>

<a href="add_staff.php">Add Staff</a>

<a href="view_staff.php">View Staff</a>

<a href="check_promotion.php">Check Promotion Eligibility</a>

</nav>

</body>

</html>

add_stuff.php

<?php include 'db.php'; ?>

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

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

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

<title>Add Academic Staff</title>

</head>

<body>

<h1>Add Academic Staff</h1>


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

<label>Name:</label>

<input type="text" name="name" required>

<label>Position:</label>

<input type="text" name="position" required>

<label>Department:</label>

<input type="text" name="department" required>

<label>Hire Date:</label>

<input type="date" name="hire_date" required>

<label>Publications:</label>

<input type="number" name="publications" required>

<label>Teaching Years:</label>

<input type="number" name="teaching_years" required>

<label>Performance Score:</label>

<input type="number" name="performance_score" step="0.1" required>

<button type="submit" name="submit">Add Staff</button>

</form>

<?php

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

$name = $_POST['name'];

$position = $_POST['position'];

$department = $_POST['department'];

$hire_date = $_POST['hire_date'];

$publications = $_POST['publications'];
$teaching_years = $_POST['teaching_years'];

$performance_score = $_POST['performance_score'];

$sql = "INSERT INTO staff (name, position, department, hire_date, publications, teaching_years,
performance_score)

VALUES ('$name', '$position', '$department', '$hire_date', '$publications', '$teaching_years',


'$performance_score')";

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

echo "<p>Staff added successfully!</p>";

} else {

echo "<p>Error: " . $conn->error . "</p>";

?>

</body>

</html>

View_staff.php

<?php include 'db.php'; ?>

<!DOCTYPE html>

<html lang="en">

<head>

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

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

<title>View Academic Staff</title>

</head>

<body>

<h1>Academic Staff List</h1>

<table border="1">

<tr>

<th>ID</th>

<th>Name</th>

<th>Position</th>

<th>Department</th>

<th>Hire Date</th>

<th>Publications</th>

<th>Teaching Years</th>

<th>Performance Score</th>

</tr>

<?php

$result = $conn->query("SELECT * FROM staff");

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

echo "<tr>

<td>{$row['id']}</td>

<td>{$row['name']}</td>

<td>{$row['position']}</td>

<td>{$row['department']}</td>
<td>{$row['hire_date']}</td>

<td>{$row['publications']}</td>

<td>{$row['teaching_years']}</td>

<td>{$row['performance_score']}</td>

</tr>";

?>

</table>

</body>

</html>

Style.css

body {

font-family: Arial, sans-serif;

background-color: #f8f9fa;

margin: 20px;

h1 {

color: #333;

}
nav a {

margin-right: 15px;

text-decoration: none;

color: #007BFF;

form {

margin: 20px 0;

form label {

display: block;

margin: 10px 0 5px;

form input, form button {

padding: 10px;

width: 100%;

max-width: 400px;

margin-bottom: 15px;

table {

width: 100%;
border-collapse: collapse;

table th, table td {

padding: 10px;

text-align: left;

border: 1px solid #ddd;

ONLINE BIRTH CERTIFICATE REGISTRATION SYSTEM

birth_certificate_system/

├── index.php (Homepage)

├── register_birth.php (Register a birth)

├── view_requests.php (View all birth certificate requests)

├── approve_request.php (Approve requests)

├── db.php (Database connection)

└── css/

└── style.css (Styling)

CREATE DATABASE birth_registration;

USE birth_registration;
CREATE TABLE birth_records (

id INT AUTO_INCREMENT PRIMARY KEY,

child_name VARCHAR(100) NOT NULL,

date_of_birth DATE NOT NULL,

gender ENUM('Male', 'Female', 'Other') NOT NULL,

place_of_birth VARCHAR(100) NOT NULL,

father_name VARCHAR(100) NOT NULL,

mother_name VARCHAR(100) NOT NULL,

contact_number VARCHAR(15) NOT NULL,

status ENUM('Pending', 'Approved', 'Rejected') DEFAULT 'Pending'

);

db.php

<?php

$host = "localhost";

$username = "root"; // Replace with your MySQL username

$password = ""; // Replace with your MySQL password

$dbname = "birth_registration";

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

if ($conn->connect_error) {

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


}

?>

Index.php

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

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

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

<title>Birth Certificate Registration</title>

</head>

<body>

<h1>Online Birth Certificate Registration</h1>

<nav>

<a href="register_birth.php">Register Birth</a>

<a href="view_requests.php">View Requests</a>

</nav>

</body>

</html>

register_birth.php
<?php include 'db.php'; ?>

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

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

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

<title>Register Birth</title>

</head>

<body>

<h1>Register Birth Certificate</h1>

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

<label>Child's Name:</label>

<input type="text" name="child_name" required>

<label>Date of Birth:</label>

<input type="date" name="dob" required>

<label>Gender:</label>

<select name="gender" required>

<option value="Male">Male</option>

<option value="Female">Female</option>

<option value="Other">Other</option>

</select>

<label>Place of Birth:</label>

<input type="text" name="place_of_birth" required>


<label>Father's Name:</label>

<input type="text" name="father_name" required>

<label>Mother's Name:</label>

<input type="text" name="mother_name" required>

<label>Contact Number:</label>

<input type="text" name="contact_number" required>

<button type="submit" name="submit">Submit</button>

</form>

<?php

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

$child_name = $_POST['child_name'];

$dob = $_POST['dob'];

$gender = $_POST['gender'];

$place_of_birth = $_POST['place_of_birth'];

$father_name = $_POST['father_name'];

$mother_name = $_POST['mother_name'];

$contact_number = $_POST['contact_number'];

$sql = "INSERT INTO birth_records (child_name, date_of_birth, gender, place_of_birth,


father_name, mother_name, contact_number)

VALUES ('$child_name', '$dob', '$gender', '$place_of_birth', '$father_name', '$mother_name',


'$contact_number')";

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

echo "<p>Registration successful! Your request is pending approval.</p>";


} else {

echo "<p>Error: " . $conn->error . "</p>";

?>

</body>

</html>

View_request.php

<?php include 'db.php'; ?>

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

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

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

<title>View Requests</title>

</head>

<body>

<h1>Birth Certificate Requests</h1>


<table border="1">

<tr>

<th>ID</th>

<th>Child's Name</th>

<th>Date of Birth</th>

<th>Gender</th>

<th>Status</th>

<th>Actions</th>

</tr>

<?php

$result = $conn->query("SELECT * FROM birth_records");

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

echo "<tr>

<td>{$row['id']}</td>

<td>{$row['child_name']}</td>

<td>{$row['date_of_birth']}</td>

<td>{$row['gender']}</td>

<td>{$row['status']}</td>

<td>

<a href='approve_request.php?id={$row['id']}&status=Approved'>Approve</a> |

<a href='approve_request.php?id={$row['id']}&status=Rejected'>Reject</a>

</td>

</tr>";

?>
</table>

</body>

</html>

Approve_request.php

<?php include 'db.php'; ?>

<?php

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

$id = $_GET['id'];

$status = $_GET['status'];

$sql = "UPDATE birth_records SET status = '$status' WHERE id = $id";

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

echo "<p>Request updated successfully!</p>";

} else {

echo "<p>Error: " . $conn->error . "</p>";

?>

<a href="view_requests.php">Go Back</a>


style.css

body {

font-family: Arial, sans-serif;

margin: 20px;

background-color: #f8f9fa;

h1 {

color: #333;

nav a {

margin-right: 15px;

text-decoration: none;

color: #007BFF;

form {

margin: 20px 0;

form label {

display: block;
margin: 10px 0 5px;

form input, form select, form button {

padding: 10px;

width: 100%;

max-width: 400px;

margin-bottom: 15px;

table {

width: 100%;

border-collapse: collapse;

margin: 20px 0;

table th, table td {

border: 1px solid #ddd;

padding: 10px;

text-align: left;

a{

color: #007BFF;

text-decoration: none;
}

Add user authentication

USE birth_registration;

CREATE TABLE users (

id INT AUTO_INCREMENT PRIMARY KEY,

username VARCHAR(100) NOT NULL,

password VARCHAR(255) NOT NULL,

role ENUM('user', 'admin') DEFAULT 'user'

);

birth_certificate_system/

├── index.php (Homepage)

├── register_birth.php (Register a birth)

├── register_user.php (User registration)

├── login.php (User login)


├── view_requests.php (Admin view requests)

├── approve_request.php (Approve or reject requests)

├── logout.php (Logout)

├── db.php (Database connection)

├── css/

└── style.css (Styling)

CREATE DATABASE birth_registration;

USE birth_registration;

-- Create users table for authentication

CREATE TABLE users (

id INT AUTO_INCREMENT PRIMARY KEY,

username VARCHAR(100) NOT NULL,

password VARCHAR(255) NOT NULL,

role ENUM('user', 'admin') DEFAULT 'user'

);

-- Create birth_records table for storing birth certificates

CREATE TABLE birth_records (

id INT AUTO_INCREMENT PRIMARY KEY,

child_name VARCHAR(100) NOT NULL,


date_of_birth DATE NOT NULL,

gender ENUM('Male', 'Female', 'Other') NOT NULL,

place_of_birth VARCHAR(100) NOT NULL,

father_name VARCHAR(100) NOT NULL,

mother_name VARCHAR(100) NOT NULL,

contact_number VARCHAR(15) NOT NULL,

status ENUM('Pending', 'Approved', 'Rejected') DEFAULT 'Pending'

);

db.php

<?php

$host = "localhost";

$username = "root"; // Replace with your MySQL username

$password = ""; // Replace with your MySQL password

$dbname = "birth_registration";

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

if ($conn->connect_error) {

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

?>
register_user.php

<?php

include 'db.php';

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

$username = $_POST['username'];

$password = password_hash($_POST['password'], PASSWORD_DEFAULT); // Encrypt the password

$role = 'user'; // Default role for users

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

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

echo "Registration successful. You can now log in.";

} else {

echo "Error: " . $conn->error;

?>

<!DOCTYPE html>

<html lang="en">

<head>
<meta charset="UTF-8">

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

<title>User Registration</title>

</head>

<body>

<h2>Register</h2>

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

<label>Username:</label>

<input type="text" name="username" required><br>

<label>Password:</label>

<input type="password" name="password" required><br>

<button type="submit" name="register">Register</button>

</form>

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

</body>

</html>

Login.php

<?php

session_start();

include 'db.php';

if (isset($_POST['login'])) {
$username = $_POST['username'];

$password = $_POST['password'];

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

$result = $conn->query($sql);

if ($result->num_rows > 0) {

$row = $result->fetch_assoc();

// Verify password

if (password_verify($password, $row['password'])) {

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

$_SESSION['username'] = $row['username'];

$_SESSION['role'] = $row['role']; // Store user role (admin or user)

// Redirect to homepage

header("Location: index.php");

} else {

echo "Invalid credentials.";

} else {

echo "No user found with that username.";

?>
<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

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

<title>Login</title>

</head>

<body>

<h2>Login</h2>

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

<label>Username:</label>

<input type="text" name="username" required><br>

<label>Password:</label>

<input type="password" name="password" required><br>

<button type="submit" name="login">Login</button>

</form>

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

</body>

</html>
Logout.php

<?php

session_start();

session_destroy();

header("Location: index.php");

exit;

?>

Index.php

<?php session_start(); ?>

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

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

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

<title>Birth Certificate Registration</title>

</head>

<body>

<h1>Online Birth Certificate Registration</h1>

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


<p>Welcome, <?php echo $_SESSION['username']; ?>!</p>

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

<nav>

<a href="register_birth.php">Register Birth</a>

<a href="view_requests.php">View Requests</a>

</nav>

<?php else: ?>

<nav>

<a href="register_birth.php">Register Birth</a>

</nav>

<?php endif; ?>

<a href="logout.php">Logout</a>

<?php else: ?>

<p><a href="login.php">Login</a> | <a href="register_user.php">Register</a></p>

<?php endif; ?>

</body>

</html>
register_birth.php

<?php

session_start();

include 'db.php';

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

header("Location: login.php");

exit;

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

$child_name = $_POST['child_name'];

$dob = $_POST['dob'];

$gender = $_POST['gender'];

$place_of_birth = $_POST['place_of_birth'];

$father_name = $_POST['father_name'];

$mother_name = $_POST['mother_name'];

$contact_number = $_POST['contact_number'];

$sql = "INSERT INTO birth_records (child_name, date_of_birth, gender, place_of_birth, father_name,


mother_name, contact_number)

VALUES ('$child_name', '$dob', '$gender', '$place_of_birth', '$father_name', '$mother_name',


'$contact_number')";

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

echo "<p>Registration successful! Your request is pending approval.</p>";


} else {

echo "<p>Error: " . $conn->error . "</p>";

?>

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

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

<title>Register Birth</title>

</head>

<body>

<h2>Register Birth Certificate</h2>

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

<label>Child's Name:</label>

<input type="text" name="child_name" required><br>

<label>Date of Birth:</label>

<input type="date" name="dob" required><br>

<label>Gender:</label>

<select name="gender" required>

<option value="Male">Male</option>

<option value="Female">Female</option>

<option value="Other">Other</option>
</select><br>

<label>Place of Birth:</label>

<input type="text" name="place_of_birth" required><br>

<label>Father's Name:</label>

<input type="text" name="father_name" required><br>

<label>Mother's Name:</label>

<input type="text" name="mother_name" required><br>

<label>Contact Number:</label>

<input type="text" name="contact_number" required><br>

<button type="submit" name="submit">Submit</button>

</form>

</body>

</html>

Views_request.php

<?php

session_start();

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

header("Location: index.php");

exit;

}
include 'db.php';

$result = $conn->query("SELECT * FROM birth_records");

echo "<h2>View Birth Certificate Requests</h2>";

echo "<table border='1'>

<tr>

<th>ID</th>

<th>Child's Name</th>

<th>Date of Birth</th>

<th>Status</th>

<th>Actions</th>

</tr>";

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

echo "<tr>

<td>{$row['id']}</td>

<td>{$row['child_name']}</td>

<td>{$row['date_of_birth']}</td>

<td>{$row['status']}</td>

<td><a href='approve_request.php?id={$row['id']}&status=Approved'>Approve</a> |

<a href='approve_request.php?id={$row['id']}&status=Rejected'>Reject</a></td>

</tr>";

echo "</table>";
?>

Approve_request.php

<?php

session_start();

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

header("Location: index.php");

exit;

include 'db.php';

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

$id = $_GET['id'];

$status = $_GET['status'];

$sql = "UPDATE birth_records SET status = '$status' WHERE id = $id";

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

echo "Request updated successfully!";

} else {

echo "Error: " . $conn->error;


}

?>

<a href="view_requests.php">Go Back</a>

Style.css

body {

font-family: Arial, sans-serif;

margin: 20px;

background-color: #f8f9fa;

h1 {

color: #333;

form {

margin: 20px 0;

form label {
display: block;

margin: 10px 0 5px;

form input, form select, form button {

padding: 10px;

width: 100%;

max-width: 400px;

margin-bottom: 15px;

a{

color: #007BFF;

text-decoration: none;

a:hover {

text-decoration: underline;

table {

width: 100%;

border-collapse: collapse;

margin: 20px 0;

}
table th, table td {

border: 1px solid #ddd;

padding: 10px;

text-align: left;

ONLINE GAS DELIVERY SYSTEM

gas_delivery_system/

├── index.php (Homepage)

├── register_user.php (User Registration)

├── login.php (User Login)

├── order.php (Order Gas)

├── view_orders.php (Admin View Orders)

├── logout.php (Logout)

├── db.php (Database Connection)

├── css/

└── style.css (Styling)

CREATE DATABASE gas_delivery;


USE gas_delivery;

-- Create users table for user authentication

CREATE TABLE users (

id INT AUTO_INCREMENT PRIMARY KEY,

username VARCHAR(100) NOT NULL,

password VARCHAR(255) NOT NULL,

role ENUM('user', 'admin') DEFAULT 'user'

);

-- Create orders table for storing gas orders

CREATE TABLE orders (

id INT AUTO_INCREMENT PRIMARY KEY,

user_id INT NOT NULL,

order_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,

quantity INT NOT NULL,

status ENUM('Pending', 'Delivered') DEFAULT 'Pending',

FOREIGN KEY (user_id) REFERENCES users(id)

);

db.php

<?php
$host = "localhost"; // Database server

$username = "root"; // MySQL username

$password = ""; // MySQL password

$dbname = "gas_delivery"; // Database name

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

if ($conn->connect_error) {

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

?>

register_user.php

<?php

include 'db.php';

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

$username = $_POST['username'];

$password = password_hash($_POST['password'], PASSWORD_DEFAULT); // Encrypt password

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


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

echo "Registration successful. You can now log in.";

} else {

echo "Error: " . $conn->error;

?>

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

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

<title>User Registration</title>

</head>

<body>

<h2>Register</h2>

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

<label>Username:</label>

<input type="text" name="username" required><br>

<label>Password:</label>

<input type="password" name="password" required><br>

<button type="submit" name="register">Register</button>

</form>

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


</body>

</html>

login.php

<?php

session_start();

include 'db.php';

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

$username = $_POST['username'];

$password = $_POST['password'];

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

$result = $conn->query($sql);

if ($result->num_rows > 0) {

$row = $result->fetch_assoc();

// Verify password

if (password_verify($password, $row['password'])) {

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

$_SESSION['username'] = $row['username'];

$_SESSION['role'] = $row['role'];
// Redirect to homepage

header("Location: index.php");

} else {

echo "Invalid credentials.";

} else {

echo "No user found with that username.";

?>

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

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

<title>Login</title>

</head>

<body>

<h2>Login</h2>

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

<label>Username:</label>

<input type="text" name="username" required><br>

<label>Password:</label>

<input type="password" name="password" required><br>


<button type="submit" name="login">Login</button>

</form>

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

</body>

</html>

Logout.php

<?php

session_start();

session_destroy();

header("Location: index.php");

exit;

?>

index.php

<?php session_start(); ?>

<!DOCTYPE html>

<html lang="en">

<head>

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

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

<title>Gas Delivery System</title>

</head>

<body>

<h1>Online Gas Delivery System</h1>

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

<p>Welcome, <?php echo $_SESSION['username']; ?>!</p>

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

<nav>

<a href="view_orders.php">View Orders</a>

</nav>

<?php else: ?>

<nav>

<a href="order.php">Order Gas</a>

</nav>

<?php endif; ?>

<a href="logout.php">Logout</a>

<?php else: ?>

<p><a href="login.php">Login</a> | <a href="register_user.php">Register</a></p>

<?php endif; ?>

</body>
</html>

order.php

<?php

session_start();

include 'db.php';

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

header("Location: login.php");

exit;

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

$quantity = $_POST['quantity'];

$user_id = $_SESSION['user_id'];

$sql = "INSERT INTO orders (user_id, quantity) VALUES ('$user_id', '$quantity')";

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

echo "Order placed successfully!";

} else {

echo "Error: " . $conn->error;


}

?>

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

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

<title>Order Gas</title>

</head>

<body>

<h2>Order Gas</h2>

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

<label>Quantity (in KG):</label>

<input type="number" name="quantity" required><br>

<button type="submit" name="order">Place Order</button>

</form>

</body>

</html>
view_orders.php

<?php

session_start();

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

header("Location: index.php");

exit;

include 'db.php';

$result = $conn->query("SELECT * FROM orders");

echo "<h2>View Orders</h2>";

echo "<table border='1'>

<tr>

<th>Order ID</th>

<th>User ID</th>

<th>Quantity</th>

<th>Status</th>

<th>Actions</th>

</tr>";

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

echo "<tr>

<td>{$row['id']}</td>
<td>{$row['user_id']}</td>

<td>{$row['quantity']}</td>

<td>{$row['status']}</td>

<td>

<a href='approve_order.php?id={$row['id']}&status=Delivered'>Approve</a> |

<a href='approve_order.php?id={$row['id']}&status=Rejected'>Reject</a>

</td>

</tr>";

echo "</table>";

?>

Approve_order.php

<?php

session_start();

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

header("Location: index.php");

exit;

include 'db.php';
if (isset($_GET['id']) && isset($_GET['status'])) {

$id = $_GET['id'];

$status = $_GET['status'];

// Update the order status (either 'Delivered' or 'Rejected')

$sql = "UPDATE orders SET status = '$status' WHERE id = $id";

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

echo "Order status updated successfully!";

header("Location: view_orders.php"); // Redirect back to orders list

} else {

echo "Error: " . $conn->error;

?>

Style.css

body {

font-family: Arial, sans-serif;

background-color: #f4f4f9;

margin: 0;

padding: 0;

}
h1, h2 {

color: #333;

text-align: center;

nav {

text-align: center;

margin: 20px;

nav a {

margin: 0 10px;

text-decoration: none;

color: #0066cc;

form {

width: 300px;

margin: 0 auto;

background-color: white;

padding: 20px;

border-radius: 8px;

box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);

}
form input {

width: 100%;

padding: 10px;

margin: 10px 0;

border-radius: 5px;

border: 1px solid #ccc;

form button {

width: 100%;

padding: 10px;

background-color: #0066cc;

color: white;

border: none;

border-radius: 5px;

cursor: pointer;

form button:hover {

background-color: #004d99;

table {

width: 80%;

margin: 20px auto;


border-collapse: collapse;

table, th, td {

border: 1px solid #ccc;

text-align: center;

padding: 10px;

th {

background-color: #f1f1f1;

Background image

/* Basic Reset */

*{

margin: 0;

padding: 0;

box-sizing: border-box;

body {
font-family: Arial, sans-serif;

background-image: url('path-to-your-image.jpg'); /* Add the path to your background image */

background-size: cover;

background-position: center center;

background-attachment: fixed;

color: #fff;

margin: 0;

padding: 0;

display: flex;

flex-direction: column;

align-items: center;

justify-content: center;

min-height: 100vh;

h1, h2 {

color: #fff;

text-align: center;

text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.6);

nav {

text-align: center;

margin: 20px;

}
nav a {

margin: 0 10px;

text-decoration: none;

color: #00bfff; /* Light blue color */

font-size: 1.2em;

transition: color 0.3s ease;

nav a:hover {

color: #ff6600; /* Orange color on hover */

/* Form Styles */

form {

background-color: rgba(0, 0, 0, 0.6); /* Semi-transparent black background */

padding: 30px;

border-radius: 10px;

box-shadow: 0 0 15px rgba(0, 0, 0, 0.3);

width: 100%;

max-width: 400px;

margin: 20px auto;

form label {
font-size: 1.1em;

margin-bottom: 8px;

display: block;

color: #fff;

form input {

width: 100%;

padding: 12px;

margin: 10px 0;

border-radius: 8px;

border: 2px solid #ddd;

background-color: #f4f4f4;

form input:focus {

border-color: #00bfff;

outline: none;

background-color: #fff;

form button {

width: 100%;

padding: 12px;

background-color: #00bfff;
color: white;

border: none;

border-radius: 8px;

cursor: pointer;

font-size: 1.1em;

transition: background-color 0.3s ease;

form button:hover {

background-color: #ff6600;

/* Table Styles */

table {

width: 80%;

margin: 20px auto;

border-collapse: collapse;

background-color: rgba(0, 0, 0, 0.5); /* Semi-transparent background for table */

border-radius: 10px;

table th, table td {

padding: 15px;

text-align: center;

border: 1px solid #ddd;


}

table th {

background-color: #333;

color: #fff;

text-transform: uppercase;

table td {

background-color: #f9f9f9;

color: #333;

table td a {

color: #ff6600;

text-decoration: none;

table td a:hover {

color: #00bfff;

/* Responsive Design */

@media (max-width: 768px) {

body {
padding: 10px;

form {

width: 90%;

margin: 10px;

table {

width: 100%;

margin-top: 15px;

MOVIE SYSTEM

CREATE DATABASE movies_db;

USE movies_db;

CREATE TABLE users (

id INT AUTO_INCREMENT PRIMARY KEY,

username VARCHAR(100) UNIQUE NOT NULL,

password VARCHAR(255) NOT NULL

);
CREATE TABLE movies (

id INT AUTO_INCREMENT PRIMARY KEY,

title VARCHAR(255) NOT NULL,

description TEXT,

release_date DATE

);

CREATE TABLE reviews (

id INT AUTO_INCREMENT PRIMARY KEY,

movie_id INT NOT NULL,

user_name VARCHAR(100),

review TEXT,

rating INT CHECK(rating BETWEEN 1 AND 5),

FOREIGN KEY (movie_id) REFERENCES movies(id) ON DELETE CASCADE

);

<?php

// File: db.php (Database connection)

$host = 'localhost';

$user = 'root';

$password = '';

$dbname = 'movies_db';
$conn = new mysqli($host, $user, $password, $dbname);

if ($conn->connect_error) {

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

?>

Add_movie.php

<?php include('db.php'); ?>

<!DOCTYPE html>

<html>

<head>

<title>Add Movie</title>

</head>

<body>

<h1>Add Movie</h1>

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

<label for="title">Title:</label>

<input type="text" id="title" name="title" required><br>

<label for="description">Description:</label>
<textarea id="description" name="description" required></textarea><br>

<label for="release_date">Release Date:</label>

<input type="date" id="release_date" name="release_date" required><br>

<button type="submit" name="add_movie">Add Movie</button>

</form>

<?php

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

$title = $_POST['title'];

$description = $_POST['description'];

$release_date = $_POST['release_date'];

$sql = "INSERT INTO movies (title, description, release_date) VALUES (?, ?, ?)";

$stmt = $conn->prepare($sql);

$stmt->bind_param('sss', $title, $description, $release_date);

if ($stmt->execute()) {

echo "<p>Movie added successfully!</p>";

} else {

echo "<p>Error: " . $stmt->error . "</p>";

?>

</body>

</html>
Review_movie.php

<?php include('db.php'); ?>

<!DOCTYPE html>

<html>

<head>

<title>Submit/View/Edit Review</title>

</head>

<body>

<h1>Reviews</h1>

<?php

// Fetch all movies

$movies = $conn->query("SELECT * FROM movies");

?>

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

<label for="movie_id">Select Movie:</label>

<select id="movie_id" name="movie_id" required>

<?php while ($movie = $movies->fetch_assoc()): ?>

<option value="<?= $movie['id']; ?>"><?= $movie['title']; ?></option>


<?php endwhile; ?>

</select><br>

<label for="user_name">Your Name:</label>

<input type="text" id="user_name" name="user_name" required><br>

<label for="review">Review:</label>

<textarea id="review" name="review" required></textarea><br>

<label for="rating">Rating (1-5):</label>

<input type="number" id="rating" name="rating" min="1" max="5" required><br>

<button type="submit" name="submit_review">Submit/Update Review</button>

</form>

<?php

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

$movie_id = $_POST['movie_id'];

$user_name = $_POST['user_name'];

$review = $_POST['review'];

$rating = $_POST['rating'];

// Check if review exists

$check = $conn->query("SELECT * FROM reviews WHERE movie_id = $movie_id AND user_name =


'$user_name'");

if ($check->num_rows > 0) {

// Update existing review

$sql = "UPDATE reviews SET review = ?, rating = ? WHERE movie_id = ? AND user_name = ?";

$stmt = $conn->prepare($sql);
$stmt->bind_param('siis', $review, $rating, $movie_id, $user_name);

$stmt->execute();

echo "<p>Review updated successfully!</p>";

} else {

// Insert new review

$sql = "INSERT INTO reviews (movie_id, user_name, review, rating) VALUES (?, ?, ?, ?)";

$stmt = $conn->prepare($sql);

$stmt->bind_param('issi', $movie_id, $user_name, $review, $rating);

$stmt->execute();

echo "<p>Review added successfully!</p>";

?>

<!-- Display Reviews -->

<h2>All Reviews</h2>

<?php

$result = $conn->query("

SELECT movies.title, reviews.user_name, reviews.review, reviews.rating

FROM reviews

JOIN movies ON reviews.movie_id = movies.id

");

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

?>

<p><strong>Movie:</strong> <?= $row['title']; ?></p>


<p><strong>User:</strong> <?= $row['user_name']; ?></p>

<p><strong>Review:</strong> <?= $row['review']; ?></p>

<p><strong>Rating:</strong> <?= $row['rating']; ?></p>

<hr>

<?php endwhile; ?>

</body>

</html>

register.php

<?php include('db.php'); ?>

<!DOCTYPE html>

<html>

<head>

<title>Register</title>

</head>

<body>

<h1>Register</h1>

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

<label for="username">Username:</label>
<input type="text" id="username" name="username" required><br>

<label for="password">Password:</label>

<input type="password" id="password" name="password" required><br>

<button type="submit" name="register">Register</button>

</form>

<?php

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

$username = $_POST['username'];

$password = password_hash($_POST['password'], PASSWORD_DEFAULT);

$sql = "INSERT INTO users (username, password) VALUES (?, ?)";

$stmt = $conn->prepare($sql);

$stmt->bind_param('ss', $username, $password);

if ($stmt->execute()) {

echo "<p>Registration successful! <a href='login.php'>Login here</a></p>";

} else {

echo "<p>Error: " . $stmt->error . "</p>";

?>

</body>

</html>
Login.php

<?php include('db.php'); ?>

<!DOCTYPE html>

<html>

<head>

<title>Login</title>

</head>

<body>

<h1>Login</h1>

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

<label for="username">Username:</label>

<input type="text" id="username" name="username" required><br>

<label for="password">Password:</label>

<input type="password" id="password" name="password" required><br>

<button type="submit" name="login">Login</button>

</form>

<?php

session_start();

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

$username = $_POST['username'];
$password = $_POST['password'];

$sql = "SELECT * FROM users WHERE username = ?";

$stmt = $conn->prepare($sql);

$stmt->bind_param('s', $username);

$stmt->execute();

$result = $stmt->get_result();

$user = $result->fetch_assoc();

if ($user && password_verify($password, $user['password'])) {

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

$_SESSION['username'] = $user['username'];

header("Location: index.php");

exit;

} else {

echo "<p>Invalid username or password.</p>";

?>

</body>

</html>
Logout.php

<?php

session_start();

session_destroy();

header("Location: login.php");

exit;

?>

Index.php

<?php

session_start();

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

header("Location: login.php");

exit;

include('db.php');

?>

<!DOCTYPE html>

<html>

<head>

<title>Home</title>
</head>

<body>

<h1>Welcome, <?= htmlspecialchars($_SESSION['username']); ?></h1>

<a href="logout.php">Logout</a>

<hr>

<!-- The rest of the page code (movies and reviews display) -->

</body>

</html>

You might also like