<?php
require'includes/head2.php';
require 'header.php';
      

require '../connections/conn.php';
if(isset($_POST['submit']))
{
	$id=$_POST['id'];
	$a=$_POST['a'];
	$n=$_POST['n'];
	$m=$_POST['m'];
	$p=$_POST['p'];
	if($a=="") $a=0;
	$check="select * from `patient` where `p_name`='$n'";
	$check_r=$conn->query($check);
	
		$p="update `patient` set `p_name`='$n',`p_age`='$a',`p_mobile`='$m',`place`='$p'  where `p_id`='$id'";
		$r=$conn->query($p);
		echo "<script type='text/javascript'>
		           window.location.href='patient_list.php'
		        </script>";
	
	
}
$id=$_GET['p_id'];
$p="select * from `patient` where `p_id`='$id'";
$r=$conn->query($p);
while($row=mysqli_fetch_array($r))
{
?>
<h3>Edit Patient</h3><hr /><br>
<form action="" method="POST">
<input type="hidden" name="id" value="<?php echo $row['p_id'];?>"><br>
<table border=0>
	<tr>
		<td><h2>Name</h2></td>
		<td><input style="font-size:20pt;width:12em; background-color:#ffffff; border-style:none" type="text" name="n" value="<?php echo $row['p_name'];?>"></td>
	</tr>
	<tr>
		<td><h2>Age</h2></td>
		<td><input style="font-size:20pt;width:12em; background-color:#ffffff; border-style:none" type="date" name="a" value="<?php echo $row['p_age'];?>"></td>
	</tr>
	<tr>
		<td><h2>Mobile</h2></td>
		<td><input style="font-size:20pt;width:12em; background-color:#ffffff; border-style:none" type="text" name="m" value="<?php echo $row['p_mobile'];?>"></td>
	</tr>
	<tr>
		<td><h2>Address</h2></td>
		<td><input style="font-size:20pt;width:12em; background-color:#ffffff; border-style:none" type="text" name="p" value="<?php echo $row['place'];?>"></td>
	</tr>
	<tr>
		<td></td>
		<td style="text-align:center"><input style="font-size:20pt;width:12em; background-color:#000000; border-style:none; color:#ffffff" type="submit" name="submit"></td>
		
	</tr>
</table>
</form>
<?php } 
require 'includes/foot.php';?>