Solved

I want to receive 1 or 2 input values

Posted on 2000-03-16
1
133 Views
Last Modified: 2010-03-05
I want to receive 1 or 2 input values from internet users in order to make searches in an ascii file and i want the searching results to be aligned in the web page.
2)How this script can be executed from my page
May I have an example.
Thank you
0
Comment
Question by:vage78
1 Comment
 
LVL 3

Accepted Solution

by:
guadalupe earned 15 total points
ID: 2627837
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>

</HEAD>

<BODY BGCOLOR="#FFFFFF">
<FORM METHOD=POST ACTION="/cgi-bin/script.cgi">
<INPUT TYPE="text" NAME="val1">
<INPUT TYPE="text" NAME="val2">
</FORM>
</BODY>
</HTML>



######################################
#CGI Script: script.cgi


#!/usr/local/bin/perl

&parseInput;


#Rest of code

#This will leaves all variables in a hash called %fields where the key is the
#Name of the form field and the value the value of the correspnding field.
#!!!!Be carefull with checkboxs they are only sent as form elements if they are
#checked...





#---------------------------------Parse Input---------------------------------------#
#                  Arguments:      NONE                                                                                    #
#                  Purpose            Standard Form/Query String Parsing                                          #
#                  Calls:            NONE                                                                                    #
#-----------------------------------------------------------------------------------#

sub parseInput()
{
      #Parse form variables
      if ($ENV{'REQUEST_METHOD'} eq "POST")
      {
            read(STDIN, $temp, $ENV{'CONTENT_LENGTH'});
      }

      elsif ($ENV{'REQUEST_METHOD'} eq "GET" )
      {
            $temp = $ENV{'QUERY_STRING'};
      }

      @pairs=split(/&/,$temp);
      
      foreach $item(@pairs)
      {
            ($key,$content)=split (/=/,$item,2);
            $content=~tr/+/ /;
            $content=~ s/%(..)/pack("c",hex($1))/ge;
            $fields{$key}=$content;
      }

}
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
use perl to insert into MySQL database 9 121
Perl output collect 7 64
Perl Awk Need Help 3 94
Writing a parser for java language 4 61
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This video discusses moving either the default database or any database to a new volume.

706 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now