Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Passing params to a php file via perl cgi script.

by dmmiller2k (Chaplain)
on Jan 20, 2002 at 02:12 UTC ( [id://140139]=note: print w/replies, xml ) Need Help??


in reply to Passing params to a php file via perl cgi script.

I'll bet what's happening is that your cgi script is being called with the following parameters:

  • url=http://www.asite.com/result.php
  • mode=n
  • color=blue
  • age=18

As a result, when you attempt to call your get() subroutine with the value of the 'url' parameter, you are only passing 'http://www.asite.com/result.php'.

To avoid this, you should replace the non-alpha (e.g., ? and &) characters in your url to their encoded equivalents:

  • & => %26
  • / => %2F
  • : => %3A
  • = => %3D
  • ? => %3F
  • etc. (look up the rest)

Which would mean calling your cgi script with the following as a 'url' parameter:

http://www.mysite.com/cgi-bin/my_perl.cgi?url=http%3A%2F%2Fwww.asite.com%2Fresult.php%3Fmode%3Dn%26color%3Dblue%26age%3D18

dmm

If you GIVE a man a fish you feed him for a day
But,
TEACH him to fish and you feed him for a lifetime

Replies are listed 'Best First'.
(jeffa) 2Re: Passing params to a php file via perl cgi script.
by jeffa (Bishop) on Jan 20, 2002 at 03:49 UTC
    "etc. (look up the rest)"

    I couldn't resist:

    my %codes = map {chr($_) => sprintf("%%%x",$_)} (0..255); print map {"$_ => " . $codes{$_} . "\n"} qw(& / : = ?);
    But, URI::Escape is much better.

    jeffa

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    B--B--B--B--B--B--B--B--
    H---H---H---H---H---H---
    (the triplet paradiddle with high-hat)
    

      URI::Escape is the way to go if you're comfortable using modules ...

      dmm

      If you GIVE a man a fish you feed him for a day
      But,
      TEACH him to fish and you feed him for a lifetime

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://140139]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (6)
As of 2024-04-18 21:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found