<?php include_once 'database.php';
if(count($_POST)>0) {
date_default_timezone_set("Asia/Kathmandu");
$insertdate = date("Y-m-d H:i:s");
$img = file_get_contents($_FILES['image']['tmp_name']);
mysqli_query($conn,"update report set id='" . $_POST['id'] . "', name='" . $_POST['name'] . "', contactno='" . $_POST['contactno'] . "', address='" . $_POST['address'] . "' ,labno='" . $_POST['labno'] . "',age='" . $_POST['age'] . "',gender='" . $_POST['gender'] . "',refdoctor='" . $_POST['refdoctor'] . "',image='" . $img . "' WHERE id='" . $_GET['id'] . "'");
if(mysqli_affected_rows($conn)){
$message = "Record Modified Successfully";
}else{
$message = "Record Not Modified Successfully";
}
}
?>
<?php
$id = isset($_GET['id']) ? $_GET['id'] : '';
$result = mysqli_query($conn,"SELECT * FROM report WHERE id='$id'");
$row= mysqli_fetch_array($result);
?>
<!doctype html>
<meta charset="utf-8">
<title>form add
<div class="container-fluid">
<div class="panel panel-default">
<div class="panel-heading" style="background-color: aqua">
<h3 class="panel-title" style="text-align: center">Add form</h3>
</div>
<div class="panel-body">
<div><?php if(isset($message)) { echo $message; } ?>
</div>
<div style="padding-bottom: 5px">
<a href="display.php">Patient Report</a>
</div>
<table class="table table-bordered table-responsive"><tbody><tr> <td>ID.</td><td>
</td> </tr> <tr> <td>Name.</td> <td></td> </tr> <tr> <td>Contact No.</td> <td></td> </tr> <tr> <td>Address</td> <td></td> </tr><tr> <td>Lab No.</td> <td></td> </tr><tr> <td>Age</td> <td></td> </tr><tr> <td>Gender</td> <td> <div class="col-sm-6">
<input type="radio" name="gender" id="gender1" value="male"<?php echo $row['gender']=="male"?>/>Male
<input type="radio" name="gender" id="gender2" value="female"<?php echo $row['gender']=="female" ?>/>Female
</div></td> </tr><tr> <td>Ref.Doctor</td> <td></td> </tr><tr> <td>Insert Report Img.</td> <td> <?php echo ''; ?>
</td> </tr><tr> <td colspan="2" style="text-align: center; background-color: aqua">
</td> </tr></tbody></table>
<?
mysqli_close($conn);
?>
</div>
<div class="panel-footer" style="text-align: center">"We Wish You a Good Health"</div>
</div>
</div>
What I have tried:
<?php include_once 'database.php';
if(count($_POST)>0) {
date_default_timezone_set("Asia/Kathmandu");
$insertdate = date("Y-m-d H:i:s");
$img = file_get_contents($_FILES['image']['tmp_name']);
mysqli_query($conn,"update report set id='" . $_POST['id'] . "', name='" . $_POST['name'] . "', contactno='" . $_POST['contactno'] . "', address='" . $_POST['address'] . "' ,labno='" . $_POST['labno'] . "',age='" . $_POST['age'] . "',gender='" . $_POST['gender'] . "',refdoctor='" . $_POST['refdoctor'] . "',image='" . $img . "' WHERE id='" . $_GET['id'] . "'");
if(mysqli_affected_rows($conn)){
$message = "Record Modified Successfully";
}else{
$message = "Record Not Modified Successfully";
}
}
?>