|
Server IP : 217.21.85.138 / Your IP : 216.73.216.103 Web Server : LiteSpeed System : Linux in-mum-web906.main-hosting.eu 4.18.0-553.37.1.lve.el8.x86_64 #1 SMP Mon Feb 10 22:45:17 UTC 2025 x86_64 User : u915722082 ( 915722082) PHP Version : 7.4.33 Disable Function : system, exec, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail MySQL : OFF | cURL : ON | WGET : ON | Perl : OFF | Python : OFF Directory (0755) : /home/u915722082/.nvm/../public_html/invoicebill/ |
| [ Home ] | [ C0mmand ] | [ Upload File ] |
|---|
<?php
include 'templates/header.php';
include 'templates/navbar.php';
require_once 'includes/db.php';
function safe_output($data) {
return htmlspecialchars($data, ENT_QUOTES, 'UTF-8');
}
$msg = "";
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// Validate required fields
if (!empty($_POST['name']) && !empty($_POST['form']) && isset($_POST['quantity']) && !empty($_POST['unit'])) {
$name = trim($_POST['name']);
$form = $_POST['form'];
$quantity = floatval($_POST['quantity']);
$unit = $_POST['unit'];
$stmt = $conn->prepare("INSERT INTO raw_materials (name, form, quantity, unit) VALUES (?, ?, ?, ?)");
$stmt->bind_param("ssds", $name, $form, $quantity, $unit);
if ($stmt->execute()) {
$msg = '<div class="alert alert-success">Raw material added successfully!</div>';
} else {
$msg = '<div class="alert alert-danger">Error: ' . safe_output($conn->error) . '</div>';
}
$stmt->close();
} else {
$msg = '<div class="alert alert-warning">Please fill in all required fields.</div>';
}
}
?>
<div class="container mt-4">
<h2>Raw Materials</h2>
<?php echo $msg; ?>
<!-- Form to Add Raw Material -->
<form method="POST" action="raw_materials.php">
<div class="form-group">
<label for="name">Chemical Name</label>
<input type="text" class="form-control" id="name" name="name" placeholder="Enter chemical name" required>
</div>
<div class="form-group">
<label for="form">Form</label>
<select class="form-control" id="form" name="form" required>
<option value="Liquid">Liquid</option>
<option value="Powder">Powder</option>
<option value="Granule">Granule</option>
</select>
</div>
<div class="form-group">
<label for="quantity">Quantity</label>
<input type="number" step="0.01" class="form-control" id="quantity" name="quantity" required>
</div>
<div class="form-group">
<label for="unit">Unit</label>
<select class="form-control" id="unit" name="unit" required>
<option value="Litres">Litres</option>
<option value="KG">KG</option>
</select>
</div>
<button type="submit" class="btn btn-primary">Add Raw Material</button>
</form>
<hr>
<h3>Existing Raw Materials</h3>
<table class="table table-bordered">
<thead class="thead-dark">
<tr>
<th>Chemical Name</th>
<th>Form</th>
<th>Quantity</th>
<th>Unit</th>
</tr>
</thead>
<tbody>
<?php
$result = $conn->query("SELECT * FROM raw_materials ORDER BY id DESC");
while ($row = $result->fetch_assoc()):
?>
<tr>
<td><?php echo safe_output($row['name']); ?></td>
<td><?php echo safe_output($row['form']); ?></td>
<td><?php echo safe_output($row['quantity']); ?></td>
<td><?php echo safe_output($row['unit']); ?></td>
</tr>
<?php endwhile; ?>
</tbody>
</table>
</div>
<?php include 'templates/footer.php'; ?>