Solved

Form results posted on my cgi script.

Posted on 2000-03-06
2
206 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How can I modify this Excel worksheet with a script? 15 91
Facebook React and SyntheticEvents 6 76
BATCH to EXE Converter 2 70
PS call executable Files in Order 4 31
Introduction:   Welcome to my first article ever. To begin with, the reason I write this article.  I participated in a question on Experts Exchange about the start command in Windows and there were some discussion about the usage. The discussio…
Making a simple AJAX shopping cart Couple years ago I made my first shopping cart, I used iframe and JavaScript, it was very good at that time, there were no sessions or AJAX, I used cookies on clients machine. Today we have more advanced techno…
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…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

749 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