Forum Moderators: coopster & phranque

Message Too Old, No Replies

Compare SESSION with POST / CAPTCHA

Newbie question on how to connect php and perl

         

mcibor

8:50 pm on Feb 28, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi All!

I've got a small problem - I added CAPTCHA to form and I store the image data in php session
at first I tried to add <?php?> to formmail.cgi, but it didn't work (internal server error 500).

So the question for me is how to read session data:
it's in folder /folder/session_data/sess_ here comes the id, which is stored in a cookie

HTTP_COOKIE = PHPSESSID=8f67cf6a513f325b1493fa5b682c742e

inside I have:
rnd¦s:46:"here comes the value of the cookie";

where rnd is a name of the variable, pipe (is broken via webmasterworld), s for string, 46 - length of the string, it will be 3-6 letters and numbers, no spaces nor special chars.
Then I need to check if it is the same as posted variable rnd from form
Also if post isn't empty. If it is empty, or those two data are different, then I would need script to stop.

Is there a method to do that?

Thanks in advance

Regards
Michal

PS. With php it's:

<?php
session_start(); //read session, reads cookie and sets $_SESSION variables
if(empty($_POST['rnd']) ¦¦ $_SESSION['rnd']!= $_POST['rnd']) {
echo "Wrong data";
exit;
}
?>

phranque

1:00 am on Mar 1, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



maybe you are looking for the PHP::Session perl module on CPAN [search.cpan.org].

perl_diver

2:27 am on Mar 1, 2007 (gmt 0)

10+ Year Member



edit: ignore, I misread the question

mcibor

8:01 am on Mar 6, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi, thanks for the answer,
If I knew how to install it I would use is, however as this is my first cgi script, I think I will rewrite the whole formmail.cgi to php ;) It will be easier for me this way.

Thanks anyway.
Regards
Michal