hola Posted December 9, 2007 Share Posted December 9, 2007 I have a simple form <form name=myForm> <input type="text" name="username" /> <input type="submit" value=Submit /> </form> <?PHP if(isset($_POST['submit'])){ $username=$_POST['username']; $fields = array(username); $values = array($username); $db->insert($fields,$values,'customer'); echo "data added"; } ?> I want to insert data to database table using POST method. How do i do that using ajax? Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted December 10, 2007 Share Posted December 10, 2007 check out this tutorial: http://www.captain.at/howto-ajax-form-post-request.php Quote Link to comment Share on other sites More sharing options...
duclet Posted January 1, 2008 Share Posted January 1, 2008 You might want to consider using the Prototype JavaScript framework. Get it here: http://www.prototypejs.org They also have a guide on using AJAX so read up on that. It will make things a lot easier since you don't need to worry about different browsers using different protocols. Quote Link to comment Share on other sites More sharing options...
priti Posted January 2, 2008 Share Posted January 2, 2008 I have a simple form <form name=myForm> <input type="text" name="username" /> <input type="submit" value=Submit /> </form> <?PHP if(isset($_POST['submit'])){ $username=$_POST['username']; $fields = array(username); $values = array($username); $db->insert($fields,$values,'customer'); echo "data added"; } ?> I want to insert data to database table using POST method. How do i do that using ajax? Hi, Making AJAX POST request is very easy if you are aware of simple ajax stuff. http_request = new XMLHttpRequest(); //XMLHttpRequest method has to be defined to create xmlHttprequest http_request.onreadystatechange = function() {s=alertContents(http_request)}; frmstr='name=priti?age=25&gender=f&job=yes&designation=developer'; http_request.open('POST', "./tests.php", true); http_request.send(frmstr); And if you don't want to use this go for jquery ajax.It is easy and smooth. regards Quote Link to comment Share on other sites More sharing options...
shankar23 Posted April 19, 2008 Share Posted April 19, 2008 Have you updated value into database?? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.