CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
can any one help? PLEASE!

 



Aquilo
journeyman

Jan 11, 2001, 3:29 AM

Post #1 of 6 (898 views)
can any one help? PLEASE! Can't Post

can any one help? I'm going crazy!

If I hard code the address with query strings I get the right page, but if I pass the values thru a url "http://xtram.com/communities/community.pl?Community=Ev90&Action=Site2&community_id=7809& category_id=6" the values arn't seen - what am I doing wrong?? and how do I get $in{community_id} and $in{ category_id} to be used befor the the page is retreved??

all I do is tell a deffalt sub to get the info from the sub it needs,
if ($in{'Action'} eq "Site2") { &getdata2;
} elsif ($in{'Action'} eq "JustGet") { &getter;
} else { &getdata;
}
then in &getdata; I change all the address to " http://xtram.com/communities/community.pl?Community=Ev90&Action=Site2&community_id=7809& category_id=6 " so I can pass the community_id and category_id to &getdata2; but &getdata2; is not getting the values??


if ($Site eq "Ev90") {
$data =get("http://www.ev90.com/class.ihtml?community_id=7809& category_id=6");
#$data =get("http://www.ev90.com/class.ihtml?community_id=$in{community_id}& category_id=$in{ category_id}");
}
#################################################
The hole sub::
sub getdata2 {

if ($Site eq "GeoSims") {
$data =get("http://www.geosims.com/class.ihtml?community_id=$in{community_id}& category_id=$in{ category_id}");
}
if ($Site eq "Ev90") {
$data =get("http://www.ev90.com/class.ihtml?community_id=7809&%20category_id=6");
#$data =get("http://www.ev90.com/class.ihtml?community_id=$in{community_id}& category_id=$in{ category_id}");
}
if ($Site eq "3lE") {
$data =get("http://www.3le.org/class.ihtml?community_id=$in{community_id}& category_id=$in{ category_id}");
}

$data =~ s!<a href=index.ihtml>home<\/a>+!<a href=?Community=$Site>Home<\/a>!g;
$data =~ s!<a class=\'tbl_hdr_color\' href=\"class.ihtml\?(.*?)\">+!<a href=?Community=$Site&Action=Site2&$1>!g;
$data =~ s!<img src=./images/(.*?)>+!<img src=http://www.ev90.com/images/$1>!g;
$data =~ s!<a href=regs.ihtml\?(.*?)>+!<a href=?Community=$Site&Action=JustGet&STUFF=regs.ihtml\?$1>!g;
$data =~ m#< ! - - xt-start - - >#;
$data = $';
$data =~ m#< ! - - xt-end - - >#;
$data = $`;
#print "<CENTER>";
print "$data \<br\> \n";
#print "</CENTER>";
}




sleuth
Enthusiast

Jan 11, 2001, 11:17 AM

Post #2 of 6 (887 views)
Re: can any one help? PLEASE! [In reply to] Can't Post

 
What are you using to parse the incomming data?

Sleuth



Aquilo
journeyman

Jan 12, 2001, 4:15 AM

Post #3 of 6 (877 views)
Re: can any one help? PLEASE! [In reply to] Can't Post

I was using this:

sub readcom {
read(STDIN, $input, $ENV{'CONTENT_LENGTH'});
$input = $ENV{'QUERY_STRING'} if $ENV{'QUERY_STRING'};
@query = split(/&/, $input);
foreach $pair (@query) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$in{$name} = $value;
}
}

I'm using this now:

sub readcom {

if ($ENV{'REQUEST_METHOD'} eq 'GET') {
# Split the name-value pairs
@pairs = split(/&/, $ENV{'QUERY_STRING'});
}
elsif ($ENV{'REQUEST_METHOD'} eq 'POST') {
# Get the input
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
# Split the name-value pairs
@pairs = split(/&/, $buffer);
}

foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$name =~s/%(..)/pack("c",hex($1))/ge;
$value =~s/%(..)/pack("c",hex($1))/ge;
$in{$name} = $value;
}
}

I also thought it was the parse sub too but it still don't pass the info!



Fataqui
Deleted

Jan 14, 2001, 6:26 AM

Post #4 of 6 (866 views)
Re: can any one help? PLEASE! [In reply to] Can't Post

sub get_the_cgi {
local($in, %in);
local($name, $value);

# If REQUEST_METHOD is POST, use CONTENT_LENGTH. Else, use QUERY_STRING.
if ($ENV{'REQUEST_METHOD'} eq 'POST') {
if ($ENV{'CONTENT_TYPE'}=~ m#^application/x-www-form-urlencoded$#i) {
read(STDIN, $in, $ENV{'CONTENT_LENGTH'});
}
}
else {
$in= $ENV{'QUERY_STRING'};
}
# Resolve and unencode name/value pairs into %in
foreach (split('&', $in)) {
s/\+/ /g;
($name, $value)= split('=', $_, 2);
$name=~ s/%(..)/sprintf("%c",hex($1))/ge;
$value=~ s/%(..)/sprintf("%c",hex($1))/ge;
$in{$name}.= $value;
}
return %in;
}




zanardi
journeyman

Jan 14, 2001, 5:18 PM

Post #5 of 6 (859 views)
Re: can any one help? PLEASE! [In reply to] Can't Post

ugh, I dont understand why you guys are using that slow, out-dated, insecure way of parseing forms...

use CGI;
my $obj = new CGI;

my @names = $obj->param();
for (@names) {$in{$_}=$obj->param($_)}

That can get you the same results as the above code...

My BBS


Aquilo
journeyman

Jan 15, 2001, 10:08 AM

Post #6 of 6 (845 views)
Re: can any one help? PLEASE! [In reply to] Can't Post

Thanks everyone!!
I found the problem, I forgot that I was getting the info from a webpage so any space in a url will have "% 20"
I forgot to put that in :)


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives