Passing PHP variables: Form submission vs. URL submission.

Discuss various technical topics not related to Mozilla.
old jasonb
Posts: 0
Joined: December 31st, 1969, 5:00 pm

Post Posted August 31st, 2003, 9:05 am

When you pass a variable into a cgi script via url you use the following:


But - how do you pass a variable that, itself, contains a URL with variables to be passed?

Take the following code:
Code: Select all
echo "<form method=\"post\"action=\"script.cgi\">\n";
echo "<input type=\"hidden\" name=\"name\"
      value=\"John Smith\">";
echo "<input type=\"hidden\" name=\"url\"
echo "<input type=\"submit\" value=\"Submit\">";
echo "</form>";

If I process this via a form submit, everything works just fine. In "script.cgi", I can successfully get the values of these variables ($name is "John Smith" and $url is "page2.php?var3=value3").

But I can't seem to find the syntax to do the same thing when entering everything directly via URL (bypassing a form submit).

For example:
Code: Select all

(Or even just entering the URL directly into my browser.)

That's where I'm stuck. What do I put after "url=" in order for the whole value to be passed properly? I tried this:
Code: Select all

and then passing $urlstring but that didn't work. This could be because it's a CGI script that's receiving the data and so it doesn't now how to do a urldecode properly. But - how can I get around this? Are there any escape character that can be used on the URL line?

It looks like I either need to be able to give a single command from the PHP script - or have the PHP script not wait for any kind of submit action but automatically submit the form. (I know I can do this with JavaScript, but I don't want to get involved with that.)

FWIW: I no longer need an answer in order to get anything working - I've since rewritten what the CGI did as a PHP page. However, I'd still like to know the answer just to satisfy my curiosity.

Return to MozillaZine Tech

Who is online

Users browsing this forum: Google [Bot] and 1 guest