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

cgi submit button

Status
Not open for further replies.

gshirey

Programmer
Apr 11, 2001
12
US
I'm trying to figure out how to get the "submit button" using cgi.pm to send me to a new page, running a new cgi script. Details: I have a user logged in and am asking them what they would like to do now. One of the choices is "Create a Quote for a Customer." I would like for them to be able to choose that from a drop down list, then press a submit button and go to the quote generation page. Any suggestions? Any description of the submit function would be greatly appreciated.

Thanks in advance
 
There is a FAQ in the CGI forum that might be worth taking a look at. faq452-653

Here is a simple example of a select with a submit button.
HTH

Code:
#!/usr/local/bin/perl
use CGI;
$cgi = new CGI;
$this_prog = $cgi->self_url;

# normal html start stuff
print $cgi->header,
      $cgi->start_html(-title=>"A Simple CGI Input Page");

my $some_var = $cgi->param('some_var');
if ($some_var)
    {
    print &quot;<P>You selected - $some_var</P>\n&quot;;
    }
else
    { 
    print $cgi->start_form(-method=>'POST',-action=>&quot;$this_prog&quot;),
        &quot;Make a selection: &quot;,
        $cgi->popup_menu('some_var',
        	['one','two','three','four'],
        	'one'),        
        ' ',$cgi->submit(-name=>'Submit',-value=>'submit'),
        $cgi->endform,&quot;</center>&quot;;
    }
    
# close the HTML page.
print $cgi->end_html;


keep the rudder amid ship and beware the odd typo
 
It sounds like what you want to do is a &quot;redirect&quot;. Assuming that the variable $newpage contains the FULL url of the page to go to (that's means it has to contain the &quot; and all), this code will do it:
Code:
print &quot;Location: $newpage\n\n&quot;;
Do NOT print anything else before or after this line, or it probably won't work correctly. Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top