简体   繁体   中英

Autosave PHP form

I have a form with multiple tabs. Each tab has various items (textboxes, radio buttons, drop down boxes). I need the content to be saved after 15 seconds idle or when the user clicks on a different tab/item.

Currently I am saving when the user clicks on a button. This is giving the problem that if the user is on tab x and clicks the button, the form is taken back to the first tab.

I would prefer to have the save button on the last tab. When the user is filling in the data in the different tabs, it is automatically being saved. When the user clicks on the last tab, the command button is shown and then upon clicking another save is performed and the user is taken to the main screen with all the records.

Your advice and guidance please :)

Regards,

Babu

I'd say you want to submit each tabs content (form values) using an ajax call in background when another tab is selected. That way you can have the user navigate between tabs without having to reload the whole form. And the values are handed over to some ajax endpoint on your server where they can be stored.

You can do the same for an autosave feature: set a timer, when that triggers you use an ajax call to post the form values in background.

To make your life easy use jquery for the ajax calls and jquery-ui for the tabs.

You dont save the previous tab datas until you save the datas in last tab.. because if user is not willing to save the data after moving to last tab mean.. it is waste of saving previous data and deleting it..

So you can do it in SESSION... (ie) you store the datas of each tab in session with one session ID as

$session[ID][fieldName1]
$session[ID][fieldName2]
$session[ID][fieldName3]

finally if the user click on that last button tab.. you get the datas from session and save in database USING AJAX and unset the session variables.... unset it if he clicks cancel also.....

You can also use Jquery tabs so that the complete form is on one page and the form can be saved on the last tab (with your button).

This way you don't have to worry about your data being saved until the last tab.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM