atholon Posted October 30, 2007 Share Posted October 30, 2007 I must be stupid because I can`t seem to get what I need from AJAX explanations. I am trying to find a way to make it so that when a user clicks on a "Save" button on a page, the form elements are processed and uploaded to a mysql database. I was told there are two ways to have it done. 1. You could have it submit to another page and then have it redirect you back to the form with the data entered automattically. 2. You could use AJAX. (basically that is it). Although I have not seen any AJAX examples that really show how to do that. Can anyone help me? Quote Link to comment Share on other sites More sharing options...
clang Posted October 30, 2007 Share Posted October 30, 2007 Is there a specific reason you want to use Ajax? From what you've explained it just sounds like you need a simple forum that allows users to input information, which is then saved into a database. If that's correct, you can accomplish it all with one page of PHP. No need for Ajax. Quote Link to comment Share on other sites More sharing options...
mainewoods Posted October 30, 2007 Share Posted October 30, 2007 get option 1 working first, and then if you get that working, then maybe think about option 2. The reason for that is that option 2 requires you do everything that option 1 requires plus a whole bunch of more stuff. Like for instance, option 1 requires that you create a server page that will recieve the form field values and then create an sql statement from them that will then be submitted to the db and stored and if an error occurs, return that. Guess what? Option 2 requires exactly that same thing too, except that to do it through ajax requires that you package the form fields yourself using javascript, then send them through ajax, and probably deal with a number of cross browser javascript/ajax compatability issues. The server code to process the fields recieved, however, will be nearly identical! If you are a beginner, learn and implement option 1 throughly before you worry about option 2. Quote Link to comment Share on other sites More sharing options...
atholon Posted October 30, 2007 Author Share Posted October 30, 2007 Yeah the queries are already created and the processor works...I just want to make it so that it stays on the same page when submitted...it also needs to do a file upload but I hear you can`t do that with AJAX Quote Link to comment Share on other sites More sharing options...
clang Posted October 30, 2007 Share Posted October 30, 2007 It can stay on the same page. All it has to do is have the processing direct back to the page it was input on. And you're right, you can't do file uploads with Ajax EXCLUSIVELY, but you can use Ajax in conjunction with PHP to do an upload while still having things like progress bars, although PHP does all that on it's own without Ajax. Quote Link to comment Share on other sites More sharing options...
atholon Posted October 30, 2007 Author Share Posted October 30, 2007 hmmm.. I am looking for one that doesn`t do the clicking and take a long time in some places... I realize that you can also do <form action="./somepage.php?action=post"> But I am looking for a sleaker look. If I wanted to I could do that when uploading files and use AJAX for the other stuff...you think that would work? I swear I have seen other sites like myspace that somehow uploaded without refreshing the page. 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.