php - jquery does not pass values to mysql db -


i,m trying pass text box value mysql database using jquery. nothing seems work , cannot figure out error. here's 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 connect");  mysql_select_db("ajax01") or die("failed select");  if (isset($_get['named'])) {  $named = mysql_real_escape_string($_post['named']);  }  //$named = "phptest";  mysql_query("insert `variables` (`id` , `name`) values ('' ,  '" . $named . "')");  ?> 

you sending data post

 $.post("send.php", {"named": $("named").val()} 

and checking if set:

if (isset($_get['named'])) { 

and retreiving param $_post:

$named = mysql_real_escape_string($_post['named']); 

hope got error now...

try:

if (isset($_post['named'])) { 

this should work

try in index.php

 $.post("send.php", {"named": $("#gname").val()} 

and

alert("data: " + data );} 

Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -