Skip to content

javal-medical #1770

@pc6317914-cyber

Description

@pc6317914-cyber

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)

<title>Online Pharmacy</title> <style> body { font-family: sans-serif; padding: 20px; } .medicine-card { border: 1px solid #ddd; padding: 15px; margin: 10px; display: inline-block; width: 250px; vertical-align: top; } .btn { background-color: #28a745; color: white; padding: 10px; text-decoration: none; display: block; text-align: center; } .badge { background-color: #ffc107; padding: 2px 5px; font-size: 12px; border-radius: 3px; } </style>
<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 } ?>
// Get Medicine Details based on ID
$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);
?>

<title>Place Order</title> <style> form { max-width: 400px; margin: auto; padding: 20px; border: 1px solid #ccc; } input, textarea { width: 100%; margin-bottom: 10px; padding: 8px; } button { background-color: #007bff; color: white; padding: 10px; width: 100%; border: none; cursor: pointer; } </style>

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>
Order Placed Successfully!"; echo "

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');

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions