weejay Posted November 18, 2010 Share Posted November 18, 2010 Hello, I have a form in drupal which after the user submits must be stored in a mysql db and the form values must be retained in the form. How do I do that? I have code to store it in DB but not sure how to retain the values. any help is greatly appreciated. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/219127-retain-values-after-submit-drupal-php/ Share on other sites More sharing options...
Hybride Posted November 19, 2010 Share Posted November 19, 2010 What do you mean "retaining the values on the page", so you can edit them later, or in case the user refreshes the page accidentally? If the information is stored in the database already, it's just as simple as connecting to the database and retrieving the values directly. Quote Link to comment https://forums.phpfreaks.com/topic/219127-retain-values-after-submit-drupal-php/#findComment-1136903 Share on other sites More sharing options...
weejay Posted November 19, 2010 Author Share Posted November 19, 2010 By retain I mean, I dont want the values to vanish after I click on something for ex: Save button. When I click save, the data must be saved in the db and the data must not vanish from the form. Any idea how to do that? Quote Link to comment https://forums.phpfreaks.com/topic/219127-retain-values-after-submit-drupal-php/#findComment-1136906 Share on other sites More sharing options...
Pikachu2000 Posted November 19, 2010 Share Posted November 19, 2010 That's called making the form "sticky". There are plenty of tutorials on how to accomplish it. Quote Link to comment https://forums.phpfreaks.com/topic/219127-retain-values-after-submit-drupal-php/#findComment-1136987 Share on other sites More sharing options...
weejay Posted November 23, 2010 Author Share Posted November 23, 2010 I saw how to make a form sticky but they are not working in my case. What I am doing is I have a save button which when clicked calls a php page, which saves the data to the db and am using php header section to redirect it to the same page. When I redirect, the data vanishes. I am not sure if I am doing anything wrong. How to make it work in this case? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/219127-retain-values-after-submit-drupal-php/#findComment-1138598 Share on other sites More sharing options...
weejay Posted November 23, 2010 Author Share Posted November 23, 2010 The problem I am facing is that all the form code is inside a drupal page and not as a php page. If I have a separate php page for that then it works fine. Since its within a drupal page, I am not getting what I want. Quote Link to comment https://forums.phpfreaks.com/topic/219127-retain-values-after-submit-drupal-php/#findComment-1138606 Share on other sites More sharing options...
Pikachu2000 Posted November 23, 2010 Share Posted November 23, 2010 Usinng a header redirect will clear the post array, so if you're going to do it that way, you'll need to store the values another way, possibly in a session var. Quote Link to comment https://forums.phpfreaks.com/topic/219127-retain-values-after-submit-drupal-php/#findComment-1138615 Share on other sites More sharing options...
weejay Posted November 23, 2010 Author Share Posted November 23, 2010 Thanks let me try using a session var Quote Link to comment https://forums.phpfreaks.com/topic/219127-retain-values-after-submit-drupal-php/#findComment-1138617 Share on other sites More sharing options...
weejay Posted November 23, 2010 Author Share Posted November 23, 2010 When using the header redirect, does it delete the cookie too? I was trying to use cookie instead of session as its more secure and retains value for a long time. However I could not store the value back to the form. Any thoughts? Quote Link to comment https://forums.phpfreaks.com/topic/219127-retain-values-after-submit-drupal-php/#findComment-1138682 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.