Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

CGI variables

by damian1301 (Curate)
on Sep 16, 2000 at 21:19 UTC ( #32818=perlquestion: print w/replies, xml ) Need Help??
damian1301 has asked for the wisdom of the Perl Monks concerning the following question:

Can I use
<form action="test.cgi" method="post"> <input type="text" name="thing"> </form>
and call it in the script by using $thing?

Replies are listed 'Best First'.
Re: CGI variables
by Ovid (Cardinal) on Sep 17, 2000 at 05:43 UTC
    Properly, you do something like the following:
    #!/usr/bin/perl -Tw use strict; use CGI; my $query = new CGI; $query->param('thing') =~ /^([\w\s\d]+)$/ or die "Tainted data in thin +g!"; my $thing = $1;
    That allows you to properly (and safely) access the data in "thing". The regular expression should only specify the absolute minimum necessary for program functionality. The more it allows in $1, the greater the chance for a security hole.

    Further, the or die is necessary when untainting. If the match fails, $1 could still carry the data from a previous match, thus setting $thing to an undesireable value.


Re: CGI variables
by cianoz (Friar) on Sep 16, 2000 at 21:43 UTC
    if you use you can do
    so you can access it with $NAMESPACE::thing
    importing into namespace 'main' will do the trick but is a _major_ security risk!!
    don't do that!
    (someone could override your own variables.. in PHP :)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://32818]
[shmem]: LanX: now I have to find a succinct transformation FOOL => MONK
[LanX]: yeah but Marto already proposed a new "Lex Sun-D" ...
[karlgoethebier]: the word really exists: http://www. urbandictionary. com/define.php? term=fool
[shmem]: ...possibly involving RTFM
[karlgoethebier]: big surprise!
[Eily]: LanX I try to avoid answering, but I did feel that this one post was going into much detail to prove a false claim (that SHA-1 is secure, I was just wrong about how insecure it is)
[LanX]: ironically...
[LanX]: yeah whatever ... I'm in the favorable condition to already autohiding him ... how can I judge the poor FOOLs who still see his contributions xD
[Eily]: he's been pretty saavy about threads that were implictly about him in the past. I think he might have deliberatly avoiding mentioning it for some reason (he got tired?)
[Eily]: he did mention one of his propositions: basically make it possible to ignore downvotes, by separating them more from the upvotes

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (8)
As of 2017-07-24 17:21 GMT
Find Nodes?
    Voting Booth?
    I came, I saw, I ...

    Results (356 votes). Check out past polls.