perl cgi vs php

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hello phpers,

I have a task I want to carry out in php 4.3 rather than perl 5.6.
Maybe you people can help me?
What I need to do is to catch a URL on a linux box htpp://IP/something?LinkId=1234
then I want to pop up a form to prompt for username and password.
then I need to do a MD5 hex hash ie 'test' gives
then I want the browser to point to https://IP/something?LinkId=1234&name=xxx&password=MD5hash

I have very nearly done this in perl

Like so:
use Digest::MD5 qw(md5 md5_hex md5_base64);
my $LinkId = param( 'LinkId' );
print header,
start_html('Enter Logon Details'),
h1('Enter Details'),
# h1($CustomerId),
start_form (-action => " ", -
"What's your name? ",textfield('name'),p,
"What's your password? ",password_field('password'),p,
hidden(-name => "LinkId", -default => '$LinkId').

That actually works, but the tool3.cgi although it has the 3 variables
populated as required password, the MD5 hash, username and LinkId and
I can build the https URL as required I cannot get the redirect to

I either get an unhelpful error message cannot execute tool3.cgi or
nothing happens.

So I would like you php people to give me some help - cos it is after
9 pm in the UK and this is supposed to be deployed tomorrow morning
1st thing. As much help as you wish -  from nothing cos you think I
should read the manual and browse the tutorials  (quite right too- I
will when I get some time) or  few pointers to get me started or maybe
even some code ...

Thanks in anticipation ;-)


Re: perl cgi vs php

On Jan 21, 4:20 pm, wrote:
Quoted text here. Click to load it

Hi Phil, I don't know if this is too late but --

Unless you want to use a shebang line, you should have PHP set up to
respond to all .php requests in your server first. The (non fast-) cgi
binary way of doing this in Apache would be to put this in .htaccess:

AddHandler php-cgi .php
Action php-cgi /path/to/php.cgi

A PHP script would differ from whatever perl html module you are using
there because you actually jump between PHP code and output (html)
code, so you want something like this:

if( isset( $_POST['name'] ) )
  //...check password or whatever...

  //forward request
  header( "location: something?
LinkId=&name=&pass=" .
md5( $_POST['password'] ) );
elseif( isset( $_GET['name'] ) )
  //do whatever you wanted to do when authenticated
else { ?>
<?php } ?>

Now you should take that example and figure out what is different
about how you need it, I.E. you probably want it to redirect to some
other URI instead of the same "something", and there should be enough
information in the example to figure out how to do that stuff.

Good Luck,
-Michael Placentra II | ZCE

Site Timeline