form action isnt working
hello,
i am working on a script and to make it simple to set up I am making it in one file. i am making it give the illusion of many different areas by using:
BEGIN {
use CGI::Carp qw(fatalsToBrowser);
}
use CGI qw(param header);
print header;
$section = param('section');
$function = $input{'function'};
if ($section eq "admin") { &admin; }
if ($section eq "") { &default; }
This works fine. I can link to other areas by using http://www.whatever.com/cgi-bin/scriptname.cgi?section=name
But when i try to use exactly the same technique for a form (the action is [url]http://www.whatever.com/cgi-bin/scriptname.cgi?section=name)[/url] it wont work and simply returns the default view.
to try and get around this i did:
if ($section eq "createheader") {
if ($function eq "post") {
&createheader;
}
}
but it still wont work and brings up the default view.
Does anyoneknow wghat's happening?? This is about the 3rd time i have restarted and i am getting stressed with it.
cheers
Laguna Loire posted this at 18:30 — 5th August 2000.
They have: 45 posts
Joined: Aug 2000
I do it this way:
#!/usr/bin/perl
print "Content-type: text/html\n\n"; #content is html
#get the varibles that are incoming!
if ($ENV{"REQUEST_METHOD"} eq "GET") {
$input = $ENV{QUERY_STRING};
@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;
$form{$name} = $value;
}
} else {
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;
}
}
$action = $form{'action'};
#Begin the process
if ($action eq "something") {
#do this
} elsif ($action eq "somethingelse") {
#do this
}
#end
-if you wanted to access different parts you would type in myscript.pl(or .cgi)?action=something
[Edited by Laguna Loire on 08-05-2000 at 02:32 PM]
Laguna Loire
Site Director: Laguna's Jukebox (http://jukebox.3dstream.net)
Site Admin: RPGBoards (http://rpgboards.3dstream.net)
richjb posted this at 05:17 — 6th August 2000.
They have: 193 posts
Joined: Feb 2000
BEGIN {
use CGI::Carp qw(fatalsToBrowser);
}
use CGI qw(param header);
print header;
$section = param('section');
$function = param{'function'};
if ($section eq "admin") { &admin; }
elsif ($section eq "user") { &user; }
else { &default; }
exit;
I see no reason why the above code, as edited by myself, woudn't work. Try, tell me if it doesn't. If it doesn't, please post your whole script...
Richard
[email protected]
Everyone here has a website. It's just that not all are worth posting (Mine! ).
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.