Current location: Hot Scripts Forums » Programming Languages » Perl » Passing form output more than 1 script


Passing form output more than 1 script

Reply
  #1 (permalink)  
Old 09-04-04, 02:16 PM
iwpg iwpg is offline
New Member
 
Join Date: Sep 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Question Passing form output more than 1 script

Please excuse my noviceness, but I am writing my 1st CGI script and I am stuck...

I have a form that allows numbers to be inputed and the script directs the user to a specific html page based on that number.

Instead of going straight to the results page, I am trying to first direct all queries to a page that will pass the variables to a 2nd script (like a "Searching, please wait" page)

I am having problems calling the script dynamically, (script.cgi?value=500) so this so far is not an option.

So in short, how can I use 1 script to pass form variables to a 2nd script?

I appreciate the help!
Reply With Quote
  #2 (permalink)  
Old 09-06-04, 07:38 PM
Skeleton Man Skeleton Man is offline
Community Liaison
 
Join Date: Jun 2003
Location: Australia
Posts: 406
Thanks: 0
Thanked 0 Times in 0 Posts
Perhaps post the code you have for these second script so we can see why it's not working with paramters (script.cgi?value=500). I'm assuming this is your problem ?
Reply With Quote
  #3 (permalink)  
Old 09-06-04, 10:59 PM
iwpg iwpg is offline
New Member
 
Join Date: Sep 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Post

Yes, calling the script dynamically returns the script without the values, however it works wonderful with the form.

Here is a snipplet of the code:

#!/usr/bin/perl

if ($ENV{'CONTENT_LENGTH'})
{
read(STDIN, $input, $ENV{'CONTENT_LENGTH'});

@pairs = split(/&/, $input);

foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);

$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

$INPUT{$name} = $value;
}
}

# enter numbers 150 to 399, go to a certain html page

if (($INPUT {numbers1} < 400) && ($INPUT {numbers1} > 149))

{
{
&top_html("Page Title");
}

$numbers = $INPUT {numbers1};
{
open(FILE,"150_399.htm") || die "cannot open file"; #include virtual file
@lines=<FILE>;
open(FILE2,"../menu.htm") || die "cannot open file"; #include virtual file
@lines2=<FILE2>;
$numbersgb = $numbers-170; #math from input for a table on a html page
$numbersgr = $numbersgb/2;
$numberssa = $numbers-107; #math from input for a table cell on a html page
$numberssp = $numberssa/2;
&mainbody(1);
close(FILE);
close(FILE2);
}
{
&bottom(1);
}
# enter numbers 400 to 525, go to a certain html page
# and so on...
}
elsif (($INPUT {numbers1} > 399) && ($INPUT {numbers1} < 526))
{

# the rest is just subroutines and statements
Reply With Quote
  #4 (permalink)  
Old 09-07-04, 01:14 AM
Skeleton Man Skeleton Man is offline
Community Liaison
 
Join Date: Jun 2003
Location: Australia
Posts: 406
Thanks: 0
Thanked 0 Times in 0 Posts
2 things:

1. Your form parsing code doesn't allow for GET queries (script.cgi?value=500)
2. You're re-inventing the wheel and adding unneccesary code by parsing the form yourself.

You can replace all this:
Code:
if ($ENV{'CONTENT_LENGTH'})
{
read(STDIN, $input, $ENV{'CONTENT_LENGTH'});

@pairs = split(/&/, $input);

foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);

$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

$INPUT{$name} = $value;
}
}
With this:

Code:
use CGI qw(:standard);
foreach (param()){ $INPUT{$_} = param($_); }
Your problem should go away after that..
Reply With Quote
  #5 (permalink)  
Old 09-07-04, 09:33 AM
iwpg iwpg is offline
New Member
 
Join Date: Sep 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Lightbulb

Skeleton Man,

I truly appreciate your help, it worked great.

Thanks for your time and toleration of a newbie!!!

Mike
Reply With Quote
  #6 (permalink)  
Old 09-07-04, 04:46 PM
Skeleton Man Skeleton Man is offline
Community Liaison
 
Join Date: Jun 2003
Location: Australia
Posts: 406
Thanks: 0
Thanked 0 Times in 0 Posts
Happy to help :-)
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Classified Ads skipper23 Perl 3 11-22-05 02:22 AM
Proffesional form builder + form mail script (very cheap) cms-master.com General Advertisements 0 05-13-04 09:58 AM
Passing value from one form to another form sunilmzp ASP.NET 0 04-05-04 04:02 AM
Classified Ads skipper23 Perl 2 12-30-03 03:43 AM
live chat script, form script, autoresponder, babalu Script Requests 0 12-04-03 01:55 PM


All times are GMT -5. The time now is 03:58 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.