manageleavetype.php
Below code is my first file page I want to redirect this page form content into next file code edit.php. I want want to update the data from the next page.
<form action="" method="POST">
<tr>
<td><?php echo $type; ?></td>
<td><?php echo $des; ?></td>
<td><?php echo $time; ?></td>
<input type="hidden" name="hid" value="<?php echo $id; ?>">
<input type="hidden" name="htype" value="<?php echo $type; ?>">
<input type="hidden" name="hdes" value="<?php echo $des; ?>">
<td><input type="submit" name="del" value="DELETE">
<input type="submit" name="update" value="UPDATE">
</td></form></tr>
edit.php
This file except the code from above file and update the data that is received into MySQL database
<?php
require 'config.php';
if (isset($_POST['update'])) {
$eid = $_POST['hid'];
$que = "SELECT * FROM leavetype WHERE id='$eid'";
$exe = mysqli_query($conn, $que);
$raw = mysqli_fetch_array($exe);
}
if (isset($_POST['update'])) {
$nwtype = $_POST['ltype'];
$nwdes = $_POST['ldes'];
$que = "UPDATE leavetype SET leavetype='$nwtype',description='$nwdes' WHERE id='$eid'";
$exe = mysqli_query($conn, $que);
if ($exe) {
header("location:manageleavetype.php");
}
}
?>
<form method="POST">
<label>Leave Type</label>
<input type="text" name="ltype" value="<?php echo $raw['leavetype']; ?>">
<label>Description</label>
<input type="text" name="ldes" value="<?php echo $raw['description']; ?>">
<input type="submit" name="update" value="Update">
</form>
When I run this program following error is coming:
Notice: Undefined variable: raw in C:\wamp64\www\eLeaveSystem\edit.php on line 31