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? Link to comment https://forums.phpfreaks.com/topic/80915-how-to-post-using-ajax/ 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 Link to comment https://forums.phpfreaks.com/topic/80915-how-to-post-using-ajax/#findComment-410703 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. Link to comment https://forums.phpfreaks.com/topic/80915-how-to-post-using-ajax/#findComment-427375 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 Link to comment https://forums.phpfreaks.com/topic/80915-how-to-post-using-ajax/#findComment-427871 Share on other sites More sharing options...
shankar23 Posted April 19, 2008 Share Posted April 19, 2008 Have you updated value into database?? Link to comment https://forums.phpfreaks.com/topic/80915-how-to-post-using-ajax/#findComment-521062 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.