http://www.perlmonks.org?node_id=148114

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

HELP!!!
-------
Sorry to yell but I need some help asap.
I have a form that when submitted logs data into a db however I need to add data from the page url into the form i.e.
http://mysite.com/form.(html,.php,.plor.cgi)enter=car
were http://mysite.com/form.html is the page were the form in on.
and 'enter' is the field in the form were the data needs to go.
and 'car' is the data that is to be add into the form.
Thanks for any help you can give.
Casper

Replies are listed 'Best First'.
Re: Passing data a from URL into a form???
by data64 (Chaplain) on Feb 28, 2002 at 02:41 UTC
Re: Passing data a from URL into a form???
by funky_aunt (Acolyte) on Feb 28, 2002 at 04:29 UTC
    I highly recommend Ovid's CGI tutorial. He gives an example similar to this.
Re: Passing data a from URL into a form???
by screamingeagle (Curate) on Feb 28, 2002 at 03:55 UTC
    if what u need to know is how to prepolulate a form with data which is being passed to it , use the CGI module's param method; to use your example
    #!/usr/bin/perl use strict; use CGI qw(cgi); my $cgi = new CGI; print "<html><body><form>\n<input type=text name=car value=" . $cgi->p +aram('enter'); . "></form></body>"
    this will display the value of the 'enter' parameter (i.e. car) in the html form hth...
Re: I need some help asp.
by justinNEE (Monk) on Feb 28, 2002 at 03:21 UTC
    I might be misunderstanding the question but I think you are saying you have 'form.cgi?enter=car' that has an html form on it that submits to another file (form2.cgi) But you want enter=car to go in the database as well, is that right? Just put db code into form.cgi as well. If you really want to submit it to the database in form2.cgi, here is one way to do it: put it into a hidden field in form.cgi. It might sound like its a bad idea, but really its a horrible idea. form.cgi:
    <FORM> <INPUT NAME="newField1"> <INPUT NAME="newFIeld2"> <INPUT NAME="enter" VALUE="car"> <INPUT TYPE=SUBMIT> </FORM>