• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 215
  • Last Modified:

Form results posted on my cgi script.

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
hoster19
Asked:
hoster19
1 Solution
 
stephenbladeCommented:
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
 
hoster19Author Commented:
Thanks!

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

Hank
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now