Solved

Form results posted on my cgi script.

Posted on 2000-03-06
2
205 Views
Last Modified: 2013-12-25
How do I forward my form results in my cgi script?

This is what I got:



$indust = "AIR";                                                #Industry to search
$ticker = "dal";                                                #Stock ticker symbol to search
$state = "";                                                      #State to search
$subject= "";                                                      #Subject to search



print <<"EOF";



<TABLE BORDER=0 CELLPADDING=5 CELLSPACING=0 WIDTH=420>


<TR>
      <TD WIDTH=45 BGCOLOR="000066" VALIGN="TOP"><P>&nbsp;<BR><FONT FACE="Verdana, Geneva, sans-serif" SIZE=4 COLOR="FFFFFF"><B>2</B></FONT></TD>
      <TD ALIGN=LEFT VALIGN=MIDDLE BGCOLOR="E4E4E4"><IMG SRC="../images/topicalsearch.gif" ALT="Topical Search" WIDTH=220 HEIGHT=28>

<TABLE BORDER=0 CELLPADDING=5>
<TR>
<TD ALIGN=LEFT VALIGN=TOP>
<FORM METHOD="POST" ACTION="/prn/owa/keysearch_sa">

<INPUT TYPE="HIDDEN" NAME="LAST" VALUE="">
<INPUT TYPE="HIDDEN" NAME="TICKER" VALUE="">

<FONT FACE="Verdana, Geneva, sans-serif" SIZE=2><B>Choose an industry:</B></FONT><BR>
<SELECT name="$indus" size=1>
<OPTION SELECTED VALUE="">All Industries
<OPTION VALUE="ADV">Advertising
<OPTION VALUE="ARO">Aerospace/Defense
<OPTION VALUE="AGR">Agriculture
<OPTION VALUE="AIR">Airlines/Aviation
<OPTION VALUE="AUT">Auto
<OPTION VALUE="FIN">Banking/Financial Services
<OPTION VALUE="CHM">Chemical
<OPTION VALUE="CPR">Computer/Electronics
<OPTION VALUE="CST">Construction/Building
<OPTION VALUE="EDU">Education
<OPTION VALUE="ENT">Entertainment
<OPTION VALUE="ENV">Environmental Services
<OPTION VALUE="FOD">Food/Beverages
<OPTION VALUE="CNO">Gambling/Casinos
<OPTION VALUE="HOU">Household/Consumer/Cosmetics
<OPTION VALUE="INS">Insurance
<OPTION VALUE="LEI">Leisure/Travel/Hotels/Restaurants
<OPTION VALUE="MAC">Machinery
<OPTION VALUE="MAR">Maritime/Shipbuilding
<OPTION VALUE="MNG">Mining/Metals
<OPTION VALUE="MLM">Multimedia/Online/Internet
<OPTION VALUE="OIL">Oil/Energy
<OPTION VALUE="PAP">Paper/Forest Products/Containers
<OPTION VALUE="HEA-MTC">Pharmaceuticals/Biotech/Health Care
<OPTION VALUE="PUB">Publishing/Information Services
<OPTION VALUE="RLT">Real Estate
<OPTION VALUE="RST">Restaurants
<OPTION VALUE="REA">Retail
<OPTION VALUE="SPT">Sports
<OPTION VALUE="TLS">Telecommunications
<OPTION VALUE="TEX">Textiles
<OPTION VALUE="TOB">Tobacco
<OPTION VALUE="TRN">Transportation/Trucking/Railroads
<OPTION VALUE="UTI">Utilities
<OPTION VALUE="OTHER">Other
</SELECT>
</TD>
<TD ALIGN=LEFT  VALIGN=TOP>
<FONT FACE="Verdana, Geneva, sans-serif" SIZE=2><B>Choose a state:</B></FONT><BR>
<SELECT NAME="STATE" size=1>
<OPTION SELECTED VALUE="">All States
<OPTION VALUE="AL">Alabama
<OPTION VALUE="AK">Alaska
<OPTION VALUE="AZ">Arizona
<OPTION VALUE="AR">Arkansas
<OPTION VALUE="CA">California
<OPTION VALUE="CO">Colorado
<OPTION VALUE="CT">Connecticut
<OPTION VALUE="DE">Delaware
<OPTION VALUE="DC">District of Columbia
<OPTION VALUE="FL">Florida
<OPTION VALUE="GA">Georgia
<OPTION VALUE="HI">Hawaii
<OPTION VALUE="ID">Idaho
<OPTION VALUE="IL">Illinois
<OPTION VALUE="IN">Indiana
<OPTION VALUE="IA">Iowa
<OPTION VALUE="KS">Kansas
<OPTION VALUE="KY">Kentucky
<OPTION VALUE="LA">Louisiana
<OPTION VALUE="ME">Maine
<OPTION VALUE="MD">Maryland
<OPTION VALUE="MA">Massachusetts
<OPTION VALUE="MI">Michigan
<OPTION VALUE="MN">Minnesota
<OPTION VALUE="MS">Mississippi
<OPTION VALUE="MO">Missouri
<OPTION VALUE="MT">Montana
<OPTION VALUE="NE">Nebraska
<OPTION VALUE="NV">Nevada
<OPTION VALUE="NH">New Hampshire
<OPTION VALUE="NJ">New Jersey
<OPTION VALUE="NM">New Mexico
<OPTION VALUE="NY">New York
<OPTION VALUE="NC">North Carolina
<OPTION VALUE="ND">North Dakota
<OPTION VALUE="OH">Ohio
<OPTION VALUE="OK">Oklahoma
<OPTION VALUE="OR">Oregon
<OPTION VALUE="PA">Pennsylvania
<OPTION VALUE="PR">Puerto Rico
<OPTION VALUE="RI">Rhode Island
<OPTION VALUE="SC">South Carolina
<OPTION VALUE="SD">South Dakota
<OPTION VALUE="TN">Tennessee
<OPTION VALUE="TX">Texas
<OPTION VALUE="UT">Utah
<OPTION VALUE="VT">Vermont
<OPTION VALUE="VA">Virginia
<OPTION VALUE="WA">Washington
<OPTION VALUE="WV">West Virginia
<OPTION VALUE="WI">Wisconsin
<OPTION VALUE="WY">Wyoming
</SELECT>
</TD>
</TR>

<TR><TD ALIGN=LEFT VALIGN=TOP>
<FONT FACE="Verdana, Geneva, sans-serif" SIZE=2><B>Choose a subject:</B></FONT><BR>
<SELECT NAME="SUBJECT" size=1>
<OPTION SELECTED VALUE="">All Subjects
<OPTION VALUE="ACC">Accounting news/issues
<OPTION VALUE="TNM">Acquisitions/Mergers
<OPTION VALUE="BCY">Bankruptcy
<OPTION VALUE="BLK">Black-Oriented News
<OPTION VALUE="RTG">Bond/Stock ratings
<OPTION VALUE="LEG">Congressional and State Legislation
<OPTION VALUE="CON">Contracts
<OPTION VALUE="DIV">Dividends
<OPTION VALUE="ERN">Earnings
<OPTION VALUE="ERP">Earnings forecasts
<OPTION VALUE="ECO">Economic news/analysis
<OPTION VALUE="CPN">Election campaigns
<OPTION VALUE="EXE">Federal Executive branch
<OPTION VALUE="FNC">Financing agreements
<OPTION VALUE="HSP">Hispanic-Oriented News
<OPTION VALUE="JVN">Joint ventures
<OPTION VALUE="LBR">Labor news
<OPTION VALUE="LIC">Licensing Agreements
<OPTION VALUE="PDT">New products/services
<OPTION VALUE="OFR">Offerings
<OPTION VALUE="DSC">Oil/Gas discoveries
<OPTION VALUE="PER">Personnel Announcements
<OPTION VALUE="RLE">Real Estate Transactions
<OPTION VALUE="RCN">Restructuring/Recapitalization
<OPTION VALUE="SLS">Sales reports
<OPTION VALUE="SRP">Shareholder rights/plans
</SELECT>
</TD>

<TD  ALIGN=LEFT VALIGN=TOP>
<FONT FACE="Verdana, Geneva, sans-serif" SIZE=2><B>Enter a company name:</B></FONT><BR><INPUT NAME="COMP" TYPE=Text SIZE="27" MAXLENGTH="60"></TD>
</TR>

<TR>
      <TD ALIGN=RIGHT VALIGN=TOP COLSPAN="4"><INPUT TYPE="reset" VALUE="Reset">&nbsp;<INPUT TYPE="submit" VALUE="preview"></FORM></TD>
</TR>

</TABLE>





EOF





$server = "www.modernmenus.com";
$document= "/search=test&indust=$indust&comp=&ticker=$ticker&state=&subject=";


Last line $document= "/search=test&indust=$indust&comp=&ticker=$ticker&state=&subject="; does have the stuff I need to include my form results? How do I get form results included with it?

0
Comment
Question by:hoster19
2 Comments
 
LVL 1

Accepted Solution

by:
stephenblade earned 700 total points
ID: 2590486
Why not use something like below to get and parse the info from the form then to use the info from the form use:

$form{'NAMEOFFIELD'}

The above variable will contain the answer to the form field named NAMEOFFIELD. So to print out the answer to "Choose a subject:" on your form you would place the following in your CGI:


print $form{'SUBJECT'};

##START CODE


&get_form_data; # parse arguments from post


###ACTUAL SUBROUTINE##

##############################################
# Sub: Get Form Data
# This gets data from a post.

sub get_form_data {
      $buffer = "";
      read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
      @pairs=split(/&/,$buffer);
      foreach $pair (@pairs)
      {
            @a = split(/=/,$pair);
            $name=$a[0];
            $value=$a[1];
            $value =~ s/\+/ /g;
            $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
            $value =~ s/~!/ ~!/g;
            $value =~ s/[\n\r]/ /sg;  #remove \n
            $value =~ s/\[\]//g;  #remove []
            push (@data,$name);
            push (@data, $value);
      }
      %form=@data;
      %form;
}

###END OF CODE##
0
 

Author Comment

by:hoster19
ID: 2594541
Thanks!

Check www.modernmenus.com for reverse auction (For answering questions, and earning money)

Hank
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This tutorial will give you a fast look what you can do with WhizBase. I expect you already know how to work with HTML at least, and that you understand the basics of the internet and how the internet works. WhizBase is a server-s…
If you get a (Blue Screen of Death), your system writes a small file called a minidump. Your first step is to make certain your computer is setup to record memory dumps. Right click My Computer, choose properties. Click on the advanced tab, an…
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question