Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Passing things back to the script! Novice needs help

by Anonymous Monk
on Feb 14, 2000 at 14:11 UTC ( [id://3448]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I am a beginner to perl but have come across a problem. I would like to pass variables back to the same script without putting them in hidden fields. Is this possible. The code I tried is below - can anyone advise me?
#!/usr/local/bin/perl ########################## use CGI qw (:standard); use CGI::Carp qw(fatalsToBrowser); $q = new CGI; print $q->header; $action=$q->param(action); print $q->start_html( -TITLE=>'test,' -BGCOLOR=>'#FFFFFF'); print $q->startform('post', 'test.cgi'); print "$action"; $q->param(action,'to_be_passed_back'); $action=$q->param(action); print "$action"; print $q->submit(-name=>'submit', -value=>'submit'); print $q->endform; print $q->end_html;
Thanks P

Replies are listed 'Best First'.
Re: Passing things back to the script! Novice needs help
by btrott (Parson) on Feb 15, 2000 at 00:14 UTC
    I'm not sure why you don't want to use hidden form fields, but there are some methods in CGI.pm that let you save state to a file, then initialize a new CGI object from that file. Perhaps this might help?
    perldoc CGI
    Look up "Saving the State of the Script to a File".
Re: Passing things back to the script! Novice needs help
by Crulx (Monk) on Feb 15, 2000 at 03:37 UTC
    I'll agree with the last poster on using hidden fields. They are a quick and easy way of allowing you to save state if you have dynamically served all of the pages. Otherwise you have cookies (properly used of course) to save state. I'm pretty sure that is what CGI does to maintain which browser's state to recall in that file. Note that this could possibly screw up something if the user is clicking the forward and backward button's a lot. This would cause the state in the file to be out of sync with actual page displayed. Hidden fields do not have this problem. (state is cached in the page)
    ---
    Crulx crulx@iaxs.net
Re: Passing things back to the script! Novice needs help
by JEB (Novice) on Feb 15, 2000 at 05:58 UTC

    Combine the two -- a hidden field as a 'key' to a database containing the real state information. Load mysql and:

    use DBI;

    Check out this page -- but modify the example to also save your extra state information.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://3448]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (1)
As of 2024-04-25 00:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found