$q->param() is a method on a CGI object that retrieves a query parameter. The equivalent of $q->param('foo') in PHP is $_REQUEST['foo'].
IN PERL IT'S:
Code:
$q->param('foo')
TRANSLATION
$q = $FORM{'NAME'}
HERE IS AN EXAMPLE WRITTEN IN PERL not PHP
Code:
How to Use a Form Data in Perl
This page shows how to send information from a web page form to a perl script.
The Form
Create a standard HTML form with the input values you wish to pass to the script. For example:
<form name="myForm" method="post" action="myScript.cgi">
<input type="text" name="textfield">
<input type="hidden" name="hiddenfield" value="Secret Text">
<input type="submit" name="subbtn" value="Submit">
</form>
The Script Code
In the perl script, use a block of code like the one below to extract the form data. The comments are included to show you what is happening - you can safely remove them.
# Read the standard input (sent by the form):
read(STDIN, $FormData, $ENV{'CONTENT_LENGTH'});
# Get the name and value for each form input:
@pairs = split(/&/, $FormData);
# Then for each name/value pair....
foreach $pair (@pairs) {
# Separate the name and value:
($name, $value) = split(/=/, $pair);
# Convert + signs to spaces:
$value =~ tr/+/ /;
# Convert hex pairs (%HH) to ASCII characters:
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
# Store values in a hash called %FORM:
$FORM{$name} = $value;
}
The form's input values can now be used with a key like so: $FORM{'inputname'} , where 'inputname' is the name of the form input item. For example:
print "The following text was entered in the e text field: $FORM{'textfield'}";
print "The hidden text is: $FORM{'hiddenfield'}";
__________________ Whatever you decide, you should make sure best security methods are used and practiced. Should you really need more help, PM me.
could someone plz tell me what this function exactly does???
Code:
sub get_file_contents{
my ($filename) = @_;
my ($filesize, $filesize, $thefile);
if ((-e "$filename") > 0)
{
$filesize = (-s "$filename");
open (TFILECNTS, "$filename") || die "$filename";
read(TFILECNTS,$thefile,$filesize);
close (TFILECNTS);
}
return ($thefile);
}
Last edited by Nico; 07-07-08 at 03:46 AM.
Reason: Wrappers.
could someone plz tell me what this function exactly does???
Code:
sub get_file_contents{
my ($filename) = @_; # Accepts the data sent to it
my ($filesize, $filesize, $thefile); # declares three variables to be used later
if ((-e "$filename") > 0) # Checks to see if a file exists.
{
$filesize = (-s "$filename");# checks the size of a file
open (TFILECNTS, "$filename") || die "$filename"; #opens the file for reading
read(TFILECNTS,$thefile,$filesize); #reads the file
close (TFILECNTS); # closes the file
}
return ($thefile); returns what it read.
}
Look at the comments for answers (it's inside the quoted code you posted above). To be honest, you should read more about perl as translating it is not the purpose of this forum. Glad to help though.
__________________ Whatever you decide, you should make sure best security methods are used and practiced. Should you really need more help, PM me.