Ajax used in php basic 1st show validation pass value in mysql

ajax 0 Comments

Apply validation on input box on click pass value in ajax php mysql. pass value to another file and get value in another file and insert value in mysql data base step by step.

Ajax used in php basic 1st show validation pass value in mysql

 

<script>  
 $(document).ready(function(){  
      $('#seahaddfollow').click(function(){  
         //  var txt = $(this).val(); 
		    var txt = $("#country_name").val(); 
			if(txt != '')  
           {  
                $.ajax({  
                     url:"followupaddsearch.php",  
                     type:"post", 
					 data:"phonecode="+txt+"", 
                    success:function(data)  
                     {  
                          $('#resulfollowupaddsearch').html(data);  
                     }  
                });  
           }  
           else  
           {  
			   
                $('#resulfollowupaddsearch').html('Enter Number');                 
           }  
      });  
 });  
 </script>  

jquery.min.js






 

PHP html form code on click apply action

 

<div id="resulfollowupaddsearch" style="color:#D80D0D"> </div > // in this div show only Enter Number validition
<form role="form" method="POST">
<input type="text"  id='country_name' value="<?php echo $_POST['phonecode']; ?>" class="form-control boxed" name="phonecode" placeholder="Enter Phone" style="font-size:28px; color:
#000000; height:65px;" maxlength="15" onKeyUp="if (/\D/g.test(this.value)) this.value = this.value.replace(/\D/g,'')"/>
<button type="reset" class="btn btn-success">New Followup</button> 
<button type="button" id="seahaddfollow" name="submitseach" class="btn btn-success" style="float:right;">Search</button> 
</form>

<div id="followupshowdetaillist" style="height:385px; border:1px solid #999999">  </div> 
// in this div show database value result get in followupaddsearch.php file

 

followupaddsearch.php file code : get value in another file

Get phonecode value in followupaddsearch.php set

 

<?php
//include('config.php');
//include("sessionset.php"); 	
	$search =  $_POST['phonecode']; 
	$phonse =  $_POST['phonecode']; 
	$date = date_default_timezone_set('Asia/Kolkata');	
    $datetime =  date("Y-m-d"); 
	$datetimesec = date("h:i:sa");
	$checkadd = mysql_query("Select * from table WHERE mbl = '$phonse' order by id desc LIMIT 0,1");
    $checknoadd = mysql_num_rows($checkadd);
	   if($checknoadd >= 1){
	   echo 'This No. Alery exist';	   
	   $addnoaddnew =  mysql_query("insert into table(mbl,name,courses,city,today,quali,stdpt,state,statusall,timedate) values    ('$phonse','','$inputcourese1','$inputaddcity1','$datetime','$inputquali1','$addupinnew','$addcl','clt','$datetimesec')");	   
            }
			else{ 
			//echo "insert into table(mbl,name,courses,city,today,quali,stdpt,state,statusall) values ('$phonse','','$inputcourese1','$inputaddcity1','$datetime','$inputquali1','$addupinnew','$addcl','clt')";
			
			 $addnoadd =  mysql_query("insert into table(mbl,name,courses,city,today,quali,stdpt,state,statusall) values ('$phonse','','$inputcourese1','$inputaddcity1','$datetime','$inputquali1','$addupinnew','$addcl','clt')");
	        
			$addnoaddnew = mysql_query("insert into table(mbl,name,courses,city,today,quali,stdpt,state,statusall,timedate) values ('$phonse','','$inputcourese1','$inputaddcity1','$datetime','$inputquali1','$addupinnew','$addcl','clt','$datetimesec')");	
			
			if($addnoadd){			
			echo 'This No. New add'; 	
            }
			}
		?>