Click to See Complete Forum and Search --> : Server-Side Redirect (again)


Death on Wheels
10-13-2000, 10:00 PM
OK. Go to http://airlines.flightsimming.com/wabash

Submit the form, and you will get an error message regarding the HTTP headers not being returned. The following is my redirect script:


#Parses the form data
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}


#Prints appropriate header for page requested
if ($FORM{$NavBar} eq "blank"){
print 'Location: http://airlines.flightsimming.com/wabash/default.htm\n\n';
}

elsif ($FORM{$NavBar} eq "apply"){
print 'Location: http://airlines.flightsimming.com/wabash/apply.htm\n\n';
}

elsif ($FORM{$NavBar} eq "roster"){
print 'Location: http://airlines.flightsimming.com/wabash/roster.htm\n\n';
}

else {
print "Content-type: text/html\n\n";
print "Howdy";
print "$FORM{$NavBar}";
}


It is a Win2K host with IIS 5.0, in case you're interested. Basically, what it does is it checks the value of the drop-down list submitted to it and prints the appropriate location header for the redirect. Apparently, the cause of my problem is because when the form is submitted and processed by the script, NavBar (the drop down list box) has no value. I know this because of the output (or lack thereof) of the last few lines. NavBar is the correct name as specified in the HTML page.

CGI.PM is NOT an option.

------------------
Kurt Weber
Shell scripts? Shell scripts? We don't NEED no stinkin' shell scripts!

[This message has been edited by Death on Wheels (edited 13 October 2000).]

Sweede
10-14-2000, 11:44 AM
it would be sooooooooooooooooooooooooooooooooooooooooooooooooo ooooooooooooooooooooooooooooooooo much easier using php 4.0.2 for win32 and writing that in php

let me think of it for a few minutes and i'll show you how its done in php

Sweede
10-14-2000, 11:56 AM
<?php

$URL = "http://airlines.flightsimming.com/wabash/";
$ext = ".php";

if(isset($Navbar)){
header("Location: $URL.$Navbar.$ext");
}elseif($Navbar == "blank" | | $Navbar == "home"){
header("Location: $URL."index".$ext");
}
?>


your form would be as such....


<FORM METHOD="POST" ACTION="getnpage.pl">
<CENTER>
<SELECT NAME="NavBar">
<OPTION VALUE="blank" SELECTED>---Choose a page---
<OPTION VALUE="home">Home
<OPTION VALUE="apply">Apply to Wabash Airlines
<OPTION VALUE="roster">Roster
<OPTION VALUE="hangar">Wabash Hangar
<OPTION VALUE="timetable">Timetable
<OPTION VALUE="bases">Bases (Hubs)
<OPTION VALUE="manual">Pilots' Manual
<OPTION VALUE="scenery">Scenery
<OPTION VALUE="login">Pilot Login
<OPTION VALUE="notams">NOTAMs
<OPTION VALUE="msgboard">Message Board
<OPTION VALUE="chatroom">Chatroom
<OPTION VALUE="partners">Our Partners
<OPTION VALUE="resources">Flight Resources
<OPTION VALUE="training">Flight Training
<OPTION VALUE="events">Events
<OPTION VALUE="contact">Contact Us
<OPTION VALUE="history">Our History
</SELECT>
</CENTER>
<BR>
<CENTER>
<INPUT TYPE="Submit" VALUE="Go!">
</CENTER>
</FORM>


obviously correct for my typo's and whatnot.

every page must be the same name as the value in the <option> in the form.

i do have a totally kickass menu system if you want to use it.
it's far better than this drop down and you can include() it on your pages.

but then again, you'll need to use php, causs i hate perl http://www.linuxnewbie.org/ubb/wink.gif

Death on Wheels
10-14-2000, 11:17 PM
I had originally intended to do it in PHP, but it's not installed on the server http://www.linuxnewbie.org/ubb/frown.gif
I guess I could try it in C or C++, see if that helps. But I'd rather do it in Perl.

------------------
Kurt Weber
Shell scripts? Shell scripts? We don't NEED no stinkin' shell scripts!

Sweede
10-15-2000, 11:25 AM
i'd *****.
then when they say its unsecure, ***** even more.

perl on win32 is more insecure than windows.

Death on Wheels
10-15-2000, 12:07 PM
Regardless, this doesn't work on *NIX servers either. Obviously, the problem's in the HTML/script combination and not the platform or the server.

------------------
Kurt Weber
Shell scripts? Shell scripts? We don't NEED no stinkin' shell scripts!

Sweede
10-15-2000, 12:22 PM
what do you mean it doesnt work ?
perl or php ?

Death on Wheels
10-15-2000, 01:01 PM
Perl.

------------------
Kurt Weber
Shell scripts? Shell scripts? We don't NEED no stinkin' shell scripts!

takshaka
10-15-2000, 07:17 PM
I'm sorry that you persist in eschewing CGI.pm, especially since it would've worked just fine in this case, whereas your code cannot--you won't find data from a GET on STDIN.

Now, I know the error is simply an oversight caused when you changed the form method from POST, but that's exactly the sort of thing CGI.pm makes painless.

Death on Wheels
10-15-2000, 10:28 PM
CGI.pm is not an option because it is not installed and the server admin does not wish to install it.

------------------
Kurt Weber
Shell scripts? Shell scripts? We don't NEED no stinkin' shell scripts!

Death on Wheels
10-17-2000, 04:48 PM
Top

------------------
Kurt Weber
Shell scripts? Shell scripts? We don't NEED no stinkin' shell scripts!

takshaka
10-17-2000, 06:14 PM
I thought I answered it, but to be more specific--

You're reading and parsing STDIN, which is the way to get data from a POST transaction. That's why NavBar is always undefined. To get data from a GET request, you need to parse the query string instead. I know you have code to do that; I've seen it.

Is $NavBar a variable defined elsewhere or did you mean to use $FORM{NavBar} instead?

btw--if you can install a CGI script, you can install CGI.pm.

Death on Wheels
10-17-2000, 07:35 PM
I've tried both POST and GET--neither worked. However, you are right--it should be $FORM{NavBar}

As for CGI.pm, I only have FTP access. Although the server IS an NT box... Hmm...

------------------
Kurt Weber
Shell scripts? Shell scripts? We don't NEED no stinkin' shell scripts!