How to check pin code available or not using ajax?

Pin Check Available

File name : index.php

<html>
<head>
<title>Indian pincode search with location and courier services</title>
<script type="text/javascript" src="script.js"></script>
<link rel="stylesheet" href="style.css" />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>


<script type="text/javascript">
$(document).ready(function(){
$("#check").click(function() {
var name = $('#name').val();
if(name=="")
{
$("#disp").html("");
}
else
{
$.ajax({
type: "POST",
url: "pin_check.php",
data: "name="+ name ,
success: function(html){
$("#disp").html(html);
}
});
return false;
}
});
});
</script>

</head>

<body>




<section>

<h1>Indian Pincode search with location and courier service</h1><br>

<center>

<form method="post">
<b style="color:white;">PINCODE SEARCH:</b>
<input style="height:40px; width:200px;" id="name" type="text" name="name" />
<input style="height:40px; width:70px; " id="check" type="submit" name="check" value="check" /><br />
</form>
</center>


<center>
<div class="tbl-content">
<table cellpadding="0" cellspacing="0" border="0">
<tbody>

<h2><?php echo @$_GET['blank']; ?> </h2>
<div id="disp"></div>


</tbody>
</table>
</div>
</center>
</section>
</body>
</html>

File name : pin_check.php

<?php

$con = mysqli_connect("localhost","root"," ","indianpincode");
if(isset($_POST['name']))
{
$name=$_POST['name'];


$get="select * from Pincode where pincode='$name' ";
$query=mysqli_query($con,$get);
$row=mysqli_num_rows($query);

if($row==0)
{
echo "<h2 style='color:white;' >
Courier Company are not providing delivery services at this Pincode:
<span style='color:red;'>$name</span></h2>";
}
else{

echo"
<tr style='width:100%'>
<td style='width:15% color:#f51c4f;'><h3 style='color:black;'>PINCODE</h3></td>
<td style='width:15%'><h3 style='color:black;'>COURIER COMPANY</h3></td>
<td style='width:15%'><h3 style='color:black;'>CITY NAME</h3></td>
<td style='width:15%'><h3 style='color:black;'>STATE NAME</h3></td>
<td style='width:15%'><h3 style='color:black;'>STATE CODE</h3></td>
<td style='width:15%'><h3 style='color:black;'>COD</h3></td>
</tr>";
while($row1 = mysqli_fetch_array($query)){
$pincode = $row1['pincode'];
$courier = $row1['courier_company'];
$cityname = $row1['city_name'];
$statename = $row1['state_name'];
$statecode = $row1['state_code'];
$status = $row1['cod'];

echo"
<tr style='width:100%'>
<td style='width:15%'>$pincode</td>
<td style='width:15%'>$courier</td>
<td style='width:15%'>$cityname</td>
<td style='width:15%'>$statename</td>
<td style='width:15%'>$statecode</td>
<td style='width:15%'>$status</td>
</tr>";

}
}

}
?>





Previous Next


Trending Tutorials




Review & Rating

0.0 / 5

0 Review

5
(0)

4
(0)

3
(0)

2
(0)

1
(0)

Write Review Here