$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]);
$user_id = $_SESSION['user_id']; $prescription_path = null;
else // Logged-in user: store in database $user_id = $_SESSION['user_id']; $medicine_id = $_POST['medicine_id']; $quantity = $_POST['quantity']; online pharmacy management system project in php
-- Medicines table CREATE TABLE medicines ( id INT PRIMARY KEY AUTO_INCREMENT, name VARCHAR(200) NOT NULL, category_id INT, price DECIMAL(10,2) NOT NULL, stock INT NOT NULL, requires_prescription TINYINT DEFAULT 0, description TEXT, image VARCHAR(255), expiry_date DATE, status TINYINT DEFAULT 1, FOREIGN KEY (category_id) REFERENCES categories(id) );
Maintaining stock accuracy Solution: Use database transactions; decrement stock only after order confirmation; prevent negative stock with CHECK (stock >= 0) . $sql = "INSERT INTO medicines (name, category_id, price,
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.
// Handle image upload $image = $_FILES['image']['name']; $target = "../uploads/" . basename($image); move_uploaded_file($_FILES['image']['tmp_name'], $target); $target = "../uploads/" . basename($image)
// Check if any medicine requires prescription $has_prescription_required = false; // ... query to check cart items