Online Pharmacy Management System Project In Php (2025)

$user_id = $_SESSION['user_id']; $prescription_path = null;

-- Cart table CREATE TABLE cart ( id INT PRIMARY KEY AUTO_INCREMENT, user_id INT, medicine_id INT, quantity INT, added_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY (user_id) REFERENCES users(id), FOREIGN KEY (medicine_id) REFERENCES medicines(id) );

$sql = "INSERT INTO cart (user_id, medicine_id, quantity) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE quantity = quantity + ?"; $stmt = $pdo->prepare($sql); $stmt->execute([$user_id, $medicine_id, $quantity, $quantity]); online pharmacy management system project in php

?> <?php require_once 'includes/config.php'; if ($_SERVER['REQUEST_METHOD'] == 'POST') $name = $_POST['name']; $email = $_POST['email']; $password = password_hash($_POST['password'], PASSWORD_DEFAULT); $phone = $_POST['phone'];

1. Project Overview An Online Pharmacy Management System allows customers to browse medicines, place orders, and manage prescriptions, while administrators handle inventory, orders, and users. " " . basename($_FILES['prescription']['name'])

$sql = "INSERT INTO medicines (name, category_id, price, stock, requires_prescription, description, image) VALUES (?, ?, ?, ?, ?, ?, ?)"; $stmt = $pdo->prepare($sql); $stmt->execute([$name, $category_id, $price, $stock, $requires_prescription, $description, $image]);

// Generate unique order number $order_number = 'ORD-' . strtoupper(uniqid()); $phone])) header('Location: login.php?msg=registered')

if ($stmt->execute([$name, $email, $password, $phone])) header('Location: login.php?msg=registered'); else $error = "Registration failed. Email may already exist.";

if ($has_prescription_required && isset($ FILES['prescription'])) $target_dir = "uploads/prescriptions/"; $prescription_path = $target_dir . time() . " " . basename($_FILES['prescription']['name']); move_uploaded_file($_FILES['prescription']['tmp_name'], $prescription_path);

Scroll to Top