<h2>Reserve Asset</h2>
<form action="Student_Asset.php" method="post" enctype="multipart/form-data">
<div class="form-group">
<label for="asset_id">Asset ID:</label>
<input type="text" id="asset_id" name="asset_id" value="<?php echo $_GET['id']; ?>">
</div>
<div class="form-group">
<label for="student_id">Student ID:</label>
<input type="text" id="student_id" name="student_id" value="<?php echo $_SESSION['student_Id']; ?>">
</div>
<div class="form-group">
<label for="reservation_date">Reservation Start Date:</label>
<input style="background-color: blue;" type="date" id="start_date" name="start_date" >
</div>
<div class="form-group">
<label for="duration">Reservation End Date:</label>
<input style="background-color: green;" type="date" id="end_date" name="end_date" >
</div>
<div class="form-group">
<button type="submit" name="stud_asset">Reserve</button>
</div>
</form>
<?php
if (isset($_POST['stud_asset'])) {
echo('hello');
$id = $_GET['id'];
$studentId = $_POST['student_id'];
$start_date = $_POST['start_date'];
$end_date = $_POST['end_date'];
$status="Pending";
$insertQuery = "INSERT INTO asset(stud_ID, asset_ID, r_start_date, end_date, status) VALUES ('$studentId', '$id', '$start_date', '$end_date', '$status')";
if (mysqli_query($conn, $insertQuery)) {
echo "<script>alert('Asset reserved successfully!'); window.location='student_asset.php';</script>";
} else {
echo "<script>alert('Failed to add asset.');</script>";
}
}
mysqli_close($conn);
?>
these are the codes and for your information, even the echo does not work. so i need help to figure out where does the error come from. i have connect to database at the start of the code.