Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting from PHP

Status
Not open for further replies.

bigfly

Programmer
Joined
Nov 15, 2006
Messages
4
Location
GB
Hello, I've written a script in PHP which generates a random character the user has to type in to validate a form. Someone has a Perl script that obviously won't work with it but i thought i could convert the part of the script which checks the POST into Perl. The thing is, i know nothing about Perl so i need some help. PHP script below:

<?php
$static_key = "randomlettersandnumbershere";

if ($_POST['rand'] == md5($_POST['val'].$static_key))
{
echo "<!--Put the form process here--> The data you entered was $data";
} else {
Header("Location: $HTTP_REFERER");
}
?>

the line 'echo "<!--Put the form process here--> The data you entered was $data";' would be replaced with the entire script.

Thanks. Peter Bailey
 
Code:
use CGI;
$q=new CGI;
$static_key="randomlettersandnumbershere";
use Digest::MD5;
if ($q->param('rand') eq md5($q->param('val').$static_key){
  #we're in
} else {
  print ("Location: $ENV{'HTTP_REFERER'}");
}
Not tested, but should give enough to get a grip on it

HTH

Paul
------------------------------------
Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
I'm getting

Method Not Allowed
The requested method POST is not allowed for the URL /test/process.pl.
 
From here

Resolving 405 errors - general

405 errors often arise with the POST method. You may be trying to introduce some kind of input form on your Web site, but not all ISPs allow the POST method necessary to process the form.

All 405 errors can be traced to configuration of the Web server and security governing access to the content of the Web site, so should easily be explained by your ISP.

my guess is your webserver is set up to serve cgi's only from the cgi-bin directory on the server, check your ISP's documentation

HTH


Paul
------------------------------------
Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
if you need to be more secure, i would look into using PERL to create a JPEG image with the characters in the image, its a lot harder for bots to decode the image...

i made one for one of my forms, so if you want to know more just let me know i would be glad to help
 
But post works ok with php. The same error was made for the person wanting the script..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top