Forum Moderators: coopster & phranque

Message Too Old, No Replies

Help Requesting Form Values

Help Requesting Form Values

         

lindajames

2:01 pm on May 1, 2003 (gmt 0)

10+ Year Member



Hi,

I've made a script that reads the value of sessionID from the form that posts to it. Like this:

&ReadParse;
$sessionID = $in{'sessionID'};

sub ReadParse {
local (*in) = @_ if @_; local ($i, $loc, $key, $val);
if ($ENV{'REQUEST_METHOD'} eq "GET") {
$in = $ENV{'QUERY_STRING'};
} elsif ($ENV{'REQUEST_METHOD'} eq "POST") {
read(STDIN,$in,$ENV{'CONTENT_LENGTH'}); }
@in = split(/&/,$in);
foreach $i (0 .. $#in) {
$in[$i] =~ s/\+/ /g;
($key, $val) = split(/=/,$in[$i],2);
$key =~ s/%(..)/pack("c",hex($1))/ge;
$val =~ s/%(..)/pack("c",hex($1))/ge;
$in{$key} .= "\0" if (defined($in{$key}));
$in{$key} .= $val; }
return 1;}
$loc = $loc;

If there is no value for sessionID then i want the script to redirect to a specified URL. can anyone tell me what sort of code i need to do this

any help would be much apprecited

cheers
linda

senior mcinvale

3:51 pm on May 1, 2003 (gmt 0)

10+ Year Member



if ($sessionID == "")
{
header ("Location: somepage.php");
exit;
}

something like that?

davez1000

5:27 pm on May 1, 2003 (gmt 0)

10+ Year Member



Linda,
This will work for Perl:


if (! $in{'sessionID'}){
print "Location: thepage.html\n\n";
die;
}

or


unless ($in{'sessionID'}){
print "Location: thepage.html\n\n";
die;
}