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


	if(isset($_POST['add']))
	{	
		require '../connections/conn.php';
		
		
		$n=$_POST['p_name'];
		$m=$_POST['p_mobile'];
		
		$check="select * from `patient` where `p_name`='$n'";
		$check_r=$conn->query($check);
		if($check_row=mysqli_fetch_array($check_r))
		{
			echo "<script type='text/javascript'>
		           alert('Duplicate Name');
		        </script>";
		}
		else
		{
		
		if((isset($_POST['p_age']))&&($_POST['p_age']!=""))
		$a=$_POST['p_age'];
		else $a=0;
		if(isset($_POST['place']))
		$p=$_POST['place'];
		else $p="";
			
				$insert_country="insert into `patient`(`p_name`,`p_mobile`,`p_age`,`place`)VALUES('$n','$m','$a','$p')";
				$result = $conn->query($insert_country);
				
				echo "<script type='text/javascript'>
		           window.location.href='app_new.php'
		        </script>";
		}
		
	}
	
?>
<h3>Add Patient</h3><hr /><br>
<form action="" method="POST" enctype="multipart/form-data">
	<input style="font-size:20pt;width:12em; background-color:#ffffff; border-style:none" type="text" name="p_name" placeholder="Name" required><br><br>
	<input style="font-size:20pt;width:12em; background-color:#ffffff; border-style:none" type="text" name="p_mobile" placeholder="Mobile" required><br><br>
	<input style="font-size:20pt;width:12em; background-color:#ffffff; border-style:none" type="date" name="p_age" placeholder="Age" ><br><br>
	<input style="font-size:20pt;width:12em; background-color:#ffffff; border-style:none" type="text" name="place" placeholder="Place" ><br><br>
	<input type="submit" name="add" value="ADD" style="font-size:20pt;width:12em; background-color:#000000; border-style:none; color:#ffffff">
</form>



<?php require 'includes/foot.php';?>