[PERL] как работать с данными POST
Добавлено: 2010-02-18 13:20:22
сабж. ни одного примера не нашёл.
может как-то неправильно ищщу?
может как-то неправильно ищщу?
Пока противник рисует карты наступления, мы меняем ландшафты, причём вручную
https://forum.lissyara.su/
Код: Выделить всё
use CGI qw/:standard/;
if(request_method() eq 'POST'){
$comment = param('field_comment') if(param('field_comment') && length(param('field_comment')) < 100);
....
}
Код: Выделить всё
perldoc CGI
Код: Выделить всё
var_dump($_POST)
FETCHING A LIST OF KEYWORDS FROM THE QUERY:
@keywords = $query->keywords
If the script was invoked as the result of an <ISINDEX> search, the parsed keywords can be obtained as an array using the keywords() method.
FETCHING THE NAMES OF ALL THE PARAMETERS PASSED TO YOUR SCRIPT:
@names = $query->param
If the script was invoked with a parameter list (e.g. "name1=value1&name2=value2&name3=value3"), the param() method will return the parameter names as a list. If
the script was invoked as an <ISINDEX> script and contains a string without ampersands (e.g. "value1+value2+value3") , there will be a single parameter named
"keywords" containing the "+"-delimited keywords.
NOTE: As of version 1.5, the array of parameter names returned will be in the same order as they were submitted by the browser. Usually this order is the same as
the order in which the parameters are defined in the form (however, this isn't part of the spec, and so isn't guaranteed).
MIXING POST AND URL PARAMETERS
$color = url_param('color');
It is possible for a script to receive CGI parameters in the URL as well as in the fill-out form by creating a form that POSTs to a URL containing a query string (a
"?" mark followed by arguments). The param() method will always return the contents of the POSTed fill-out form, ignoring the URL's query string. To retrieve URL
parameters, call the url_param() method. Use it in the same way as param(). The main difference is that it allows you to read the parameters, but not set them.
Under no circumstances will the contents of the URL query string interfere with similarly-named CGI parameters in POSTed forms. If you try to mix a URL query
string with a form submitted with the GET method, the results will not be what you expect.
Код: Выделить всё
[Thu Feb 18 14:55:15 2010] [error] [client 195.93.241.11] Can't call method "keywords" on an undefined value at testperl.pl line 11., referer: http://doska.lissyara.su/aaa.html
[Thu Feb 18 14:56:45 2010] [error] [client 195.93.241.11] Can't call method "param" on an undefined value at testperl.pl line 12., referer: http://doska.lissyara.su/aaa.html
Код: Выделить всё
use CGI qw/:standard/;
Код: Выделить всё
hosting$ more ~lissyara/www/data/cgi-bin/testperl.pl
#!/usr/bin/perl -w
#
use CGI qw/:standard/;
print "Content-type: text/plain; charset=iso-8859-1\n\n";
if(request_method() eq 'POST'){
#@keywords = $query->keywords;
@names = $query->param;
foreach $key (@names)
{
print "name = $key; value = " . param($key) . "\n\n";
}
exit;
#$comment = param('domain');
if(param('domain') && length(param('domain')) > 3){
print "Content-type: text/plain; charset=iso-8859-1\n\n";
print param('domain') . "\n";
}
}
Код: Выделить всё
#!/usr/bin/perl
use CGI qw/:standard/;
print header;
print '<html><head><title>post test</title></head>';
if(request_method() eq 'POST'){
my @names = param;
print '<body>';
for $key (@names){
print '<p>', $key, '=>', param($key), '</p>';
}
print '</body>';
}else{
print '<body><form action="" method="post"><input type="text" name="login"><input type="submit" value="submit"></form></body>'
}
print '</html>';
ты написал на пэхопэ?lissyara писал(а):срослось, всем пасиба!
значит ты просто не умеешь его готовитьlissyara писал(а):нет. он плохо подходит для системного языка программирования.
потому что она встроена в пыхhizel писал(а):почему в этом дурацком phpbb3 подсветка только для пыха !?
почему? http://anton-pribora.ru/cgi-bin/post.cgilissyara писал(а):жаль что на шелле POST не разберёшь
Код: Выделить всё
% cat cgi-bin/post.cgi
#!/bin/sh
echo 'Content-type: text/html'
echo
echo '<form method="POST">'
echo ' <input type="text" name="hello" value="world">'
echo ' <input type="submit" value="send">'
echo '</form>'
echo '<pre>POST-data'
cat
echo '</pre>'
например?hizel писал(а):размазываем критические участки по всему коду
эммм, где тут пхп?hizel писал(а):пэхапэшники такие пэхапэшники
ага... учите нас перлуhizel писал(а):пэхапэшники такие пэхапэшники, о безопасности думаем в последнею очередь и размазываем критические участки по всему коду, жрите пользователи : )