Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

POSTing information to a webpage, AND going to the page

Status
Not open for further replies.

BenRussell

Programmer
Mar 12, 2001
243
US
I know how I can send some information to a webpage using the POST method (in a Perl script) and get the return value of the webpage into a scalar. However, I need to be able to POST the information to a webpage, and at the same time, have the visitor's web browser actually go to that webpage with the POSTed information.

This (in my case) cannot be accomplished by simply pointing the form to the webpage. Any ideas how to do this?

- Ben
 
Not sure I'm clear on this question, but why not just redirect to the URL and pass the data as part of it? For example (using the CGI module, of course):
Code:
print $cgi->redirect('somepage.html?var1=val1&var2=val2');
 
Ben,

When you're saying POSTing information to a webpage, do you mean you want to generate a new page based on the information that was written to the script.

<form name=&quot;fred&quot; action=&quot;/cgi-bin/somescript.pl&quot;>
<input name=&quot;him&quot; value=&quot;barney&quot;>
<input name=&quot;her&quot; value=&quot;wilma&quot;>
</form>

somescript.pl
Code:
#!/usr/bin/perl
use CGI;
$q->new CGI;
print $q->start_html();
$him = param('him');
$her=param('her');
print &quot;<h2>$him &amp; $her</h2>&quot;;
print $q->end_html();
 
I mean that a website visitor visits my website and fills out a form that is called 'script.cgi'. Then script.cgi takes their information and wants to POST their information to 'script2.cgi', but wants to redirect them to script2.cgi (with the POSTed information) as if they had originally submitted a form based on script2.cgi (instead of script.cgi).

I didnt want to append the information as suggested by ctpperlmonger because some browsers limit the amount of information that can be contained using this method, and there could be a large amount of information.

- Ben
 
Then your looking to maintain state information about a visit to a site, and use script2.cgi to generate the page based on the saved information, have a look at CGI::Session

Alternatively, you could generate the page calling the variables as CTB? suggested

OR using straightforward CGI.pm but you'll have to worry about housekeeping etc

You can post information to a form, but unless you do something with it (ie make it stateful, pass it as hidden fields, or call a script with the variables) there'll be nothing left for script2.cgi to work with

For me I'd be looking at CGI::Session on search.cpan.org

Regards
--Paul
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top