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 John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CGI Form Post Data 1

Status
Not open for further replies.

Extension

Programmer
Nov 3, 2004
311
CA
Hi,

I'm working on a form and I'm passing variables using the POST method. My form "action" contains some URL parameters.

Code:
<form action="index.pl?name=tek&time=tips" method="post">
<input type="text" name="some_name" value="some_value">
<input type="submit" value="submit" name="submit"
</form>

Once the form is parsed, I cannot check the value of both "name" and "time" params.

I know I could pass both variables through a input type hidden field but I would wondering why I can't get the values using the POST method ?

Thanks in advance

 
Extension said:
I know I could pass both variables through a input type hidden field but I would wondering why I can't get the values using the POST method ?

It's time for you to read up on some of your HTML specifications. You must use hidden fields for POST methods.

Unfortunately I do not have a handy link that I can point you to for documentation as my laptop just died. But none of the parameters in an action field register for a form in the POST method. You can include parameters for documentation purposes to end users address bar, but none of those are passed to the server or parsed by CGI. This is functioning as designed. Simply use hidden fields like you know will work.
 
CGI.pm has a method as an alternative to param() which will fetch variables from the query string AND the posted data when the post method is used. I think its this:

Code:
    $params = $q->Vars;
    print $params->{'address'};
    @foo = split("\0",$params->{'foo'});
    %params = $q->Vars;

    use CGI ':cgi-lib';
    $params = Vars;

but check the CGI.pm docs.

-------------
Kirsle.net | Kirsle's Programs and Projects
 
When you mix the two types of parameters, the "param" method will only retrieve those that are in the POSTed form. If you want to get the URL parameters too, use the "url_param" method. See here.
 
Thank you to everyone. Really appreciated.

ishnid: This is exactly what I was looking for. Thank you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top