homepage Welcome to WebmasterWorld Guest from 107.20.109.52
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
Forum Library, Charter, Moderators: coopster & jatar k & phranque

Perl Server Side CGI Scripting Forum

    
Passing set of values across multiple forms
I used freeze and thaw
jagkrish




msg:3829559
 3:23 pm on Jan 19, 2009 (gmt 0)

I'm having multiple forms in a single CGI file, and loaded one form at a time based on the button selected. I will call the functions from the main code. I have multiple fields in each form, need to pass across all the forms. I'm creating HASH for the fields and values in each form as it goes. I use "thaw" and "freeze" for converting the HASH into a single string and send it in the hidden field to the next form, and then in the next form I'm getting the String into a hash through "thaw".

The problem I'm facing is I'm not able to access the passing value in the next form, since I'm initializing the value for the HASH variable at the starting, and because of that I'm always having null value at that form.

Can some one help me to solve this issue.

Thanks,
Jagan

 

krugs




msg:3829700
 6:22 pm on Jan 19, 2009 (gmt 0)

The some what standard way of doing what you are wanting to do is using CGI::Session, which handles all the backend requirements to make the form data persistent across invocations of a CGI script. Some servers have it installed and some don't. There is also CGI::Persistent which I have never used and appears to be a fairly new module. Or you can write your own routines to handle the data that needs to be carried over from form to form.

I assume you are using Storable to freeze/thaw the data. I believe that will work but I have never tried it for a CGI script. As long as you are using a disk file to store the data it sounds like it should work. The problem might be in how you are using it, which nobody here can see.

jagkrish




msg:3830095
 4:58 am on Jan 20, 2009 (gmt 0)

Thanks Krugs.

The problem is I don't want to use Cookie or Session ID based handling to get the data from the file. I'm looking for simple solution. I will look into CGI::Persistent as you said.

janharders




msg:3831096
 8:25 am on Jan 21, 2009 (gmt 0)

are you dealing with big amounts of data to be transfered?
Usually, I'd recommend the simple approach to just add a couple of hidden fields to your form and just push in all the parameters you'd like to pass through to the next call of your cgi-script. that way, you'll just have to read the parameters with CGI.pm (or whatever you're using to get them) and "it just works".

jagkrish




msg:3831120
 9:37 am on Jan 21, 2009 (gmt 0)

Hi all,

Thanks for the replies, it just the programming error I did which lead to the above problem.

Basically what I tried to do is...

1. keep dummy value in Hash as intial value as "Dummy", 0.
2. Convert the Hash into string using "Thaw"
3. Pass it on to next form in the hidden field
4. Get the string from hidden field
5. Convert the string back to Hash using "Freeze"
6. Get the values given by the user in the previous form and update the value in the Hash (Now Hash contains both the initial value as well as the previous form activated values)
7. Repeat steps 2 to 6 in all the forms where you want the values of previous form variables

When I programmed I left the 4th step which lead to current values always in the Hash.

After 1 full day frustation I found the basic problem in the next days with in 10mts..

Break is better always.. it seems.

Anyway thanks for all the help. With this problem only I found "Only string can be passed through hidden field not Hash" while googling. Also found there is possibility to pass the Hash as Hidden field by converting Hash into string and vice versa using the "Freeze-Thaw" module available in the CPAN.

Thanks once again.
Jagan

krugs




msg:3831529
 6:31 pm on Jan 21, 2009 (gmt 0)

Well done. Taking a break can be a big help. Fresh eyes and a clear mind can be invaluable in solving a problem.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved