By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,278 Members | 1,358 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,278 IT Pros & Developers. It's quick & easy.

Retain Form Values after EDIT

100+
P: 114
Hi Fellas, i need to understand how to retain the submtted form values during an Edit/Update operation.

When i add the information from a form, i retain the form values in the following way incase there is something missing or the values are incorrect.

[PHP]<input type="text" name="camount" tabindex="4" value="<?php echo $form->value("camount"); ?>" >[/PHP]

When i edit this information i retrieve the value in the following manner

[PHP]<input type="text" name="camount" tabindex="4" value="<?php echo $camount; ?>" [/PHP]

Now when i submit this edit information, how should i retain those submmitted values if incase there is an error/mistake again because i have no where i can put something like [PHP]<?php echo $form->value("camount"); ?> [/PHP] again. Which means in an edit operation the value property of a input box is already occupied by the value from the database and as a result i dont have the place where i can retain the value submitted incase if i have to return back to the same page if there is an error or mistake in the submission. The same is for the <textarea> tag cause it doesnt have even the value property.

So please tell me what is the actual funda?
Sep 1 '08 #1
Share this Question
Share on Google+
3 Replies


nathj
Expert 100+
P: 938
Hi,

If I understand correctly (a big if I admit) then you have an input box, say a text box for example, and this contains a value stored in a database.

A user comes along and loads the page with the form and the text box and decides to edit the data and save it back to the database.

In this case you have the data they wish to save and all is well. If you wish to retain the original data as well as the new data then I suggest one of the following options.

1. Load each control on the form twice - one that the users sees and edits and one that is hidden. This would give you all the data you need.

2. When the form is submitted get the original data from the DB again to check the new data against. This would enable you to build up an update statement for only the fields that need to be updated

3. Load the form initially as read only. When the user clicks 'edit' simply take all the current vales and load them into the $_SESSION so that you have access to them when the form is submitted.

Those are my ideas for the solution. If I have missed the mark completely let me know and I'll try again.

Cheers
nathj
Sep 1 '08 #2

100+
P: 114
Yea Nathj, you are 100% rite understanding my question. And i also acknowledge you for your idea which never came to my mind before. I am sure your idea will work and i am gonna try it now only. Wish me goodluck and thankyou so much.
Sep 1 '08 #3

nathj
Expert 100+
P: 938
Yea Nathj, you are 100% rite understanding my question. And i also acknowledge you for your idea which never came to my mind before. I am sure your idea will work and i am gonna try it now only. Wish me goodluck and thankyou so much.
Hi,

I'm glad to have been of help. I'll keep an eye on this thread so if you get stuck post back with the details and the code snippet and I'll try to help more.

Cheers
nathj
Sep 1 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.