RE: How to save the state of a CGI script

2005-05-30 Thread Ankur Gupta
From: Randal L. Schwartz [mailto:[EMAIL PROTECTED] 

  Ankur == Ankur Gupta [EMAIL PROTECTED] writes:
 
 Ankur a.cgi calls b.cgi through POST method.
 
 Why?  Why?  CGI is a protocol that permits a server to launch 
 a process to handle a browser hit.
 
 YOU SHOULD NOT HAVE CGI calling EACH OTHER.

Hi Randal,

Let me rephrase. 

I call http://127.0.0.1/a.cgi . This reads a file and based on it creates a
form with select list, popups, text boxes, etc. and a submit button. 

Now this generated html page will call http://127.0.0.1/b.cgi if I click on
the submit button and pass the various parameters using POST method.

I am able to collect the parameters in b.cgi and based on it I am creating a
table(html). Now I want to sort the table on different columns(Details
already provided in my earlier mail). 

I hope I am clear this time. :(

--Ankur 

Emacs is a nice operating system, but I prefer UNIX. - Tom Christiansen



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: How to save the state of a CGI script

2005-05-30 Thread David Dorward
On Sat, May 28, 2005 at 09:57:55PM +0530, Ankur Gupta wrote:

 I read perldoc CGI and found that state of a script could be saved by the
 following function.

 $myself = $query-self_url;
 print q(a href=$myselfI'm talking to myself./a);

Not quite. If you used qq so that the string would interpolate
variables then it would create a link back to the current URL -
including the query string.
 
 print $q-start_form(-method='POST',

You cannot create POST requests using a hyperlink, in HTML the only
way to set this up is with a form. Additionally, since the data not
sent using the query string then simply reading the query string won't
include the same values.

You would need to loop through the posted data and generate form
controls (such as hidden inputs) for each value. Since the rest of
your message discusses sorting of data, you should consider that GET
is supposed to be used when retrieving any information from the server
and POST when you are changing something. (This has implications such
as GET being bookmarkable, and POST causing most browsers to warn
about resubmitting data).

-- 
David Dorward  http://dorward.me.uk


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: How to save the state of a CGI script

2005-05-30 Thread Ankur Gupta
From: David Dorward,,, [mailto:[EMAIL PROTECTED] On Behalf Of 

 On Sat, May 28, 2005 at 09:57:55PM +0530, Ankur Gupta wrote:
 
  I read perldoc CGI and found that state of a script could 
 be saved by 
  the following function.
 
  $myself = $query-self_url;
  print q(a href=$myselfI'm talking to myself./a);
 
 Not quite. If you used qq so that the string would 
 interpolate variables then it would create a link back to the 
 current URL - including the query string.
  
  print $q-start_form(-method='POST',
 
 You cannot create POST requests using a hyperlink, in HTML 
 the only way to set this up is with a form. Additionally, 
 since the data not sent using the query string then simply 
 reading the query string won't include the same values.
 
 You would need to loop through the posted data and generate 
 form controls (such as hidden inputs) for each value. Since 
 the rest of your message discusses sorting of data, you 
 should consider that GET is supposed to be used when 
 retrieving any information from the server and POST when you 
 are changing something. (This has implications such as GET 
 being bookmarkable, and POST causing most browsers to warn 
 about resubmitting data).

Thanks a lot guys for the help. I guess I have to use hidden fields. 

BTW, I am using POST just because there is no restriction on the length of
the query string which I am passing to the cgi script. I read that GET has a
max value but POST does not. Am I right? I have no reservations against
using GET but only because it has max length. My query string can be way too
long that's way I am using POST.

--Ankur 

Where does the family start? It starts with a young man falling in love with
a girl - no superior alternative has yet been found. - Guess what, my ideas
match with Sir Winston Leonard Spencer Churchill



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: How to save the state of a CGI script

2005-05-30 Thread Charles K. Clarkson
Ankur Gupta mailto:[EMAIL PROTECTED] wrote:

: Thanks a lot guys for the help. I guess I have to use hidden fields.

You could also use a session cookie.


HTH,

Charles K. Clarkson
-- 
Mobile Homes Specialist
254 968-8328




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: How to save the state of a CGI script

2005-05-30 Thread Ankur Gupta
From: Charles K. Clarkson [mailto:[EMAIL PROTECTED] 

 Ankur Gupta mailto:[EMAIL PROTECTED] wrote:
 
 : Thanks a lot guys for the help. I guess I have to use hidden fields.
 
 You could also use a session cookie.

Hi Charles, 

I am fairly new to use the CGI module. So I would like to know how a cookie
would be different from a hidden field.
I mean that I can store all the parameters in the cookie but how can I pass
the parameters to the CGI script.

--Ankur 

Software engineer: One who engineers others into writing the code for
him/her.



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: How to save the state of a CGI script

2005-05-30 Thread Charles K. Clarkson
Ankur Gupta mailto:[EMAIL PROTECTED] wrote:

: Hi Charles,

Hi.

: I am fairly new to use the CGI module. So I would like to know
: how a cookie would be different from a hidden field.

Take a look at this page. It is a general discussion about
shopping cart scripts. It gives a decent introduction to both
techniques.

 
http://ironbark.bendigo.latrobe.edu.au/subjects/CN/2004/lectures/l20.d/Lect2
0.html


: I mean that I can store all the parameters in the cookie but
: how can I pass the parameters to the CGI script.

HTTP cookies are covered near the end of the CGI.pm docs.
You may not want to hold *every* value in the cookie. Sometimes
you use the cookie to point to (sensitive) data on the server.

Take a look at CGI::Session. It has a tutorial with it,
CGI::Session::Tutorial.



HTH,

Charles K. Clarkson
-- 
Mobile Homes Specialist
254 968-8328


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: How to save the state of a CGI script

2005-05-29 Thread Randal L. Schwartz
 Ankur == Ankur Gupta [EMAIL PROTECTED] writes:

Ankur a.cgi calls b.cgi through POST method. I am collecting all the parameters
Ankur using the param function.
Ankur b.cgi draws a table based on the input from a.cgi's form. 

Ankur The table's row are initially sorted by first column. It is desired that 
I
Ankur can sort the same table by different columns by just clicking on the 
heading
Ankur of the column. 

Ankur I read perldoc CGI and found that state of a script could be saved by the
Ankur following function.

Ankur [...]
Ankur $myself = $query-self_url;
Ankur print q(a href=$myselfI'm talking to myself./a);

Ankur self_url() will return a URL, that, when selected, will reinvoke this 
script
Ankur with all its state information intact. This is most useful when you want 
to
Ankur jump around within the document using internal anchors but you don't 
want to
Ankur disrupt the current contents of the form(s). Something like this will do 
the
Ankur trick.

Ankur  $myself = $query-self_url;
Ankur  print a href=\$myself#table1\See table 1/a;
Ankur  print a href=\$myself#table2\See table 2/a;
Ankur  print a href=\$myself#yourself\See for yourself/a;
Ankur [...]

Ankur But I do not want to jump around the page but change the order of the 
file.

Ankur I tried this stupid thing and it did not work.
Ankur my $myself = $q-self_url;
Ankur print $q-start_form(-method='POST',
Ankur  -action=$myself);

Ankur I also read that the parameters can be saved into a file. I tried saving 
the
Ankur parameters and it worked.
Ankur But how do I use that information so that I can pass its contents to the
Ankur same file.

Ankur Kindly help

Ankur PS: Earlier I was using GET method and I had one or two parameters to 
pass.
Ankur So I was able to sort on different columns passing the list explicitly.

Ankur --Ankur 

Ankur Whatever games are played with us, we must play no games with ourselves. 
-
Ankur Ralph Waldo Emerson



-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
merlyn@stonehenge.com URL:http://www.stonehenge.com/merlyn/
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: How to save the state of a CGI script

2005-05-29 Thread Randal L. Schwartz
 Ankur == Ankur Gupta [EMAIL PROTECTED] writes:

Ankur a.cgi calls b.cgi through POST method.

Why?  Why?  CGI is a protocol that permits a server to launch a process
to handle a browser hit.

YOU SHOULD NOT HAVE CGI calling EACH OTHER.

:-(

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
merlyn@stonehenge.com URL:http://www.stonehenge.com/merlyn/
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




How to save the state of a CGI script

2005-05-28 Thread Ankur Gupta
Hi,

I am using CGI module.

a.cgi calls b.cgi through POST method. I am collecting all the parameters
using the param function.
b.cgi draws a table based on the input from a.cgi's form. 

The table's row are initially sorted by first column. It is desired that I
can sort the same table by different columns by just clicking on the heading
of the column. 

I read perldoc CGI and found that state of a script could be saved by the
following function.

[...]
$myself = $query-self_url;
print q(a href=$myselfI'm talking to myself./a);

self_url() will return a URL, that, when selected, will reinvoke this script
with all its state information intact. This is most useful when you want to
jump around within the document using internal anchors but you don't want to
disrupt the current contents of the form(s). Something like this will do the
trick.

 $myself = $query-self_url;
 print a href=\$myself#table1\See table 1/a;
 print a href=\$myself#table2\See table 2/a;
 print a href=\$myself#yourself\See for yourself/a;
[...]

But I do not want to jump around the page but change the order of the file.

I tried this stupid thing and it did not work.
my $myself = $q-self_url;
print $q-start_form(-method='POST',
 -action=$myself);

I also read that the parameters can be saved into a file. I tried saving the
parameters and it worked.
But how do I use that information so that I can pass its contents to the
same file.

Kindly help

PS: Earlier I was using GET method and I had one or two parameters to pass.
So I was able to sort on different columns passing the list explicitly.

--Ankur 

Whatever games are played with us, we must play no games with ourselves. -
Ralph Waldo Emerson



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response