I,m trying to pass text box value into mysql database using jquery. but nothing seems to work and I cannot figure out what the error. Here's my code.
index.php
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script type="text/javascript" src="jquery.js"></script>
</head>
<body>
<script>
$(document).ready()
$("btn").click(function() {
$.post("send.php", {"named": $("named").val()}, function(data){
alert("Data: " + data + ");}
})
});
</script>
<div>
<form id="form" method="POST" action="">
<input type="text" id="gname"/></br>
<button id="btn">Set</button>
</form>
</div>
</body>
and send.php
<?php
mysql_connect("localhost", "root", "") or die("failed to connect");
mysql_select_db("ajax01") or die("failed to select");
if (isset($_GET['named'])) {
$named = mysql_real_escape_string($_POST['named']);
}
//$named = "phptest";
mysql_query("INSERT INTO `variables` (`id` , `name`) VALUES ('' , '" . $named . "')");
?>