index.php
<html>
<head>
<script src="jquery-latest.js"></script>
<script type="text/javascript">
$(document).ready(function() {
alert('hai');
$(".sub").click(function(){
alert('hhh');
var vname=$("#iname").val();
var vmob=$("#imob").val();
alert(vname);
alert(vmob);
$.get("test.php",{Name:vname,Mob:vmob,operation:"Sub"},function(data)
{
alert( "insert successfully");
});
});
});
</script>
</head>
<body>
<form method="post">
Name:<input type="text" name="name" id="iname"><br>
Fees:<input type="text" name="mob" id="imob"><br>
<input type="button" class="sub" name="sub" value="Submit">
</form>
</body>
</html>
__________________________________________________________________________
test.php
<?php
if(isset ($_GET['operation']) && $_GET['operation']!='')
{
include_once 'connect.php';
$op=$_GET['operation'];
if($op=='Sub')
{
$Name=$_GET['Name'];
$Mob=$_GET['Mob'];
$sql = mysql_query("insert into phone values('','$Name','$Mob')");
}
}
?>
___________________________________________________________________________
connect.php
<?php
$con=mysql_connect('localhost','root','');
mysql_select_db('sinsert',$con);
?>
_____________________________________________________________________
<html>
<head>
<script src="jquery-latest.js"></script>
<script type="text/javascript">
$(document).ready(function() {
alert('hai');
$(".sub").click(function(){
alert('hhh');
var vname=$("#iname").val();
var vmob=$("#imob").val();
alert(vname);
alert(vmob);
$.get("test.php",{Name:vname,Mob:vmob,operation:"Sub"},function(data)
{
alert( "insert successfully");
});
});
});
</script>
</head>
<body>
<form method="post">
Name:<input type="text" name="name" id="iname"><br>
Fees:<input type="text" name="mob" id="imob"><br>
<input type="button" class="sub" name="sub" value="Submit">
</form>
</body>
</html>
__________________________________________________________________________
test.php
<?php
if(isset ($_GET['operation']) && $_GET['operation']!='')
{
include_once 'connect.php';
$op=$_GET['operation'];
if($op=='Sub')
{
$Name=$_GET['Name'];
$Mob=$_GET['Mob'];
$sql = mysql_query("insert into phone values('','$Name','$Mob')");
}
}
?>
___________________________________________________________________________
connect.php
<?php
$con=mysql_connect('localhost','root','');
mysql_select_db('sinsert',$con);
?>
_____________________________________________________________________
No comments:
Post a Comment