-
Notifications
You must be signed in to change notification settings - Fork 613
Description
Summary
index.php db.php admin/ css/ assets/
Details
pharmacy_shop/
├── css/
│ └── style.css (Optional styling)
├── uploads/ (Create this empty folder for prescriptions)
├── db.php (Database connection)
├── index.php (Home page - List medicines)
├── order.php (Order form with prescription logic)
└── place_order.php (Backend to save order)
<h2>Available Medicines</h2>
<?php
$sql = "SELECT * FROM medicines";
$result = mysqli_query($conn, $sql);
while($row = mysqli_fetch_assoc($result)) {
$rx_status = $row['prescription_required']; // YES or NO
?>
<div class="medicine-card">
<h3><?php echo $row['name']; ?></h3>
<p>Price: ₹<?php echo $row['price']; ?></p>
<p>Stock: <?php echo $row['stock']; ?></p>
<p>
Prescription Required:
<b><?= $rx_status == "YES" ? "<span style='color:red'>Yes</span>" : "No"; ?></b>
</p>
<a href="order.php?id=<?php echo $row['id']; ?>&rx=<?php echo $rx_status; ?>" class="btn">Buy Now</a>
</div>
<?php } ?>
$id = $_GET['id'];
$rx_req = $_GET['rx']; // YES or NO
$sql = "SELECT * FROM medicines WHERE id = $id";
$result = mysqli_query($conn, $sql);
$medicine = mysqli_fetch_assoc($result);
?>
Order:
<input type="hidden" name="medicine_name" value="<?php echo $medicine['name']; ?>">
<input type="hidden" name="price_per_unit" value="<?php echo $medicine['price']; ?>">
<label>Your Name:</label>
<input type="text" name="name" required>
<label>Mobile Number:</label>
<input type="text" name="mobile" required>
<label>Address:</label>
<textarea name="address" required></textarea>
<label>Quantity:</label>
<input type="number" name="quantity" value="1" min="1" required>
<?php if($rx_req == "YES"){ ?>
<div style="background: #fff3cd; padding: 10px; margin-bottom: 10px; border: 1px solid #ffeeba;">
<strong>⚠️ Prescription Required</strong><br>
Please upload a photo of your doctor's prescription.<br><br>
<input type="file" name="prescription" required>
</div>
<?php } ?>
<button type="submit" name="submit">Confirm Order (COD)</button>
Total Amount: ₹$total
"; echo "Go Back"; } else { echo "Error: " . mysqli_error($conn); } } ?>Additional context
INSERT INTO medicines (name, price, stock, description, image, prescription_required) VALUES
('Paracetamol 500mg', 20, 100, 'For fever and pain', 'para.jpg', 'NO'),
('Azithromycin 500mg', 120, 50, 'Antibiotic', 'azi.jpg', 'YES'),
('Cough Syrup', 85, 30, 'For dry cough', 'syrup.jpg', 'NO'),
('Sleeping Pill (Alprazolam)', 50, 20, 'Sedative', 'sleep.jpg', 'YES');