Page 1 of 1
Enter data in a form to a database
Posted: Thu May 29, 2008 1:54 pm
by junestag
Hi,
I've created a form that allows users to submit the form to a database and everything works fine as far as that goes. However, my users have requested an additional 'submit' button at the top of the page called 'save' that allows them to save what they've entered so far (they're not quite done with the record), and then they want to be able to click a 'view record' link/button that allows them to see how the end-user will view what they've entered so far. Is this possible with just php or is some javascript needed?
Either way, does anyone have any ideas on how to approach this problem?
thanks,
sage
Re: Enter data in a form to a database
Posted: Thu May 29, 2008 2:39 pm
by califdon
junestag wrote:Hi,
I've created a form that allows users to submit the form to a database and everything works fine as far as that goes. However, my users have requested an additional 'submit' button at the top of the page called 'save' that allows them to save what they've entered so far (they're not quite done with the record), and then they want to be able to click a 'view record' link/button that allows them to see how the end-user will view what they've entered so far. Is this possible with just php or is some javascript needed?
Either way, does anyone have any ideas on how to approach this problem?
thanks,
sage
Sure, you could do it any number of ways, either with javascript (smoother, no page refresh) or with php. What I would be concerned about is the concept of "saving" the data. They would NOT be doing that unless you actually saved the data in the database, using php. That would be rather a lot of programming, but it's certainly do-able. What I mean is, if you used javascript to merely reformat the data on another part of the page, the data would not really be saved, and if they closed their browser, it would be lost. On the other hand, if you really save the data in the database, a whole new set of issues must be dealt with, such as: what if the user logs off and then logs on again tomorrow, to complete the entry--how will you identify the record that was started? what if the user never returns to complete the entry? etc. So this is not so much a programming question as an application design question.
Re: Enter data in a form to a database
Posted: Thu May 29, 2008 3:11 pm
by junestag
Interesting point. After hearing your description of it I think I would prefer the JavaScript version. Is there a way that you know of to save data into some sort of JS buffer and then when they click the 'view entry' link/button it opens a new window that shows what they've saved so far - formatted the way a user would see it?
Re: Enter data in a form to a database
Posted: Thu May 29, 2008 3:23 pm
by Jade
Well, you could save it all in variables and then reproduce the page in javascript with all the variables plugged into the correct places. Although there's a downside to this as well. Because they'll think they've "saved" the data before they finish the page what happens if they leave it half way through or close it half way through? Then you'd either have to put in some kind of trigger that auto-saves what they have so far. Your best bet in my opinion is either a session or ajax that updates as they enter each thing in.
Re: Enter data in a form to a database
Posted: Thu May 29, 2008 3:49 pm
by junestag
mmm, i've always wanted an excuse to use ajax. do you know where i might find some samples of ajax code to use for an application such as this?