?> <?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'];
if ($stmt->execute([$name, $email, $password, $phone])) header('Location: login.php?msg=registered'); else $error = "Registration failed. Email may already exist."; online pharmacy management system project in php
$user_id = $_SESSION['user_id']; $prescription_path = null; decrement stock only after order confirmation
-- Orders table CREATE TABLE orders ( id INT PRIMARY KEY AUTO_INCREMENT, user_id INT, order_number VARCHAR(50) UNIQUE, total_amount DECIMAL(10,2), payment_method ENUM('cod', 'card', 'online'), order_status ENUM('pending', 'confirmed', 'shipped', 'delivered', 'cancelled') DEFAULT 'pending', prescription_uploaded VARCHAR(255), created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY (user_id) REFERENCES users(id) ); = 0) . ?>
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.
Maintaining stock accuracy Solution: Use database transactions; decrement stock only after order confirmation; prevent negative stock with CHECK (stock >= 0) .
?> <?php require_once '../includes/config.php'; require_once '../includes/auth.php'; // Ensure admin login if ($_SERVER['REQUEST_METHOD'] == 'POST') $name = $_POST['name']; $category_id = $_POST['category_id']; $price = $_POST['price']; $stock = $_POST['stock']; $requires_prescription = isset($_POST['requires_prescription']) ? 1 : 0; $description = $_POST['description'];