[100382] in RedHat Linux List

home help back first fref pref prev next nref lref last post

RE: Apache web server scripts &

daemon@ATHENA.MIT.EDU (Soffen, Matthew)
Fri Nov 20 09:34:53 1998

From: "Soffen, Matthew" <msoffen@iso-ne.com>
To: redhat-list-request@redhat.com, aromes@microtec.net
Cc: linux-admin@vger.rutgers.edu, redhat-list@redhat.com
Date: Fri, 20 Nov 1998 09:36:39 -0500
Resent-From: redhat-list@redhat.com
Reply-To: redhat-list@redhat.com

A couple of things:

1) Index.html is a Web Pag, query.pl is a script *g*  (just correcting
the terms).

2) Your line:
	<INPUT TYPE= TEXT NAME= USERNAME SIZE= 25 MAXLEGTH= 50 VALUE= >

    Should be
	<INPUT TYPE="TEXT" NAME="USERNAME" SIZE="25" MAXLEGTH="50"
VALUE="">

    This is just "more" correct.  What you had is valid but not totally
correct.

3) The reason your script isn't answering is because it has a lot of
bugs.  If you get rid of the 1st 2 lines you can test this at the
command line.  You type this command at your prompt
	setenv QUERY_STRING "USERNAME=spike"
This will be read by your script.

Also, your script is doing more than it needs to.  The remove_escapes is
part of cgi-lib.pl (when you call ReadParse, it gets done).

If all you want to do is "capture" the passed parameter, you need to do
something like:

#!/usr/bin/perl

require ("cgi-lib.pl");
&ReadParse;

> print <<EOF;
> Content-type: text/html
> 
> Thank you, $in{ USERNAME }, for submitting your comments. ;
> 
> 
> 
> ----------
> From: 	aromes@microtec.net[SMTP:aromes@microtec.net]
> Sent: 	Friday, November 20, 1998 3:15 AM
> To: 	redhat-list-request@redhat.com
> Cc: 	linux-admin@vger.rutgers.edu; redhat-list@redhat.com
> Subject: 	Apache web server scripts & 
> 
> Hi,
> On my Apache web server, I ve created this little index.html 
	+script:
> <HTML>
> <HEAD><TITLE>My web page</TITLE></HEAD>
> <BODY>
> <P>
> <FORM ACTION= /home/httpd/cgi-bin/query.pl METHOD=POST>
> Enter Your name:
> <INPUT TYPE= TEXT NAME= USERNAME SIZE= 25 MAXLEGTH= 50
> VALUE= >
> </P>
> </FORM>
> </BODY>
> </HTML>
> Now, with my browser, Lynx, I can see a Nice entry that asks me
> to enter a Username, of course.
> So, I went picking up a username on the fly and press enter.
> Of course, My browser wont reply..probably because that username
> I entered is strange to him. And here comes my question:
> Say. I want to be able to enter a username called "spike"
> for ie..and being able to get an output..or something to go around.
> I guess I should create a cgi script file with the entry
> "spike" mentionned somewhere..could anyone write a little quick cgi
> script
> that can make that work..just to get the idea.
> Cause what I mainly want  is to have my script responding with
> with search results based on keyword "spike". As it;s a beginning, a
> little
> script will help ..just to get the concept.
> Well, I ve created following /home/httpd/cgi-bin/query.pl file, 
> but it seems full of errors cause my html form seems not to cooperate
> with it:
> #Contents of /home/httpd/cgi-bin/query.pl
> if ($ENV {REQUEST_METHOD } ne POST ) {
> 	&send_error_page( Page was not accessed with POST operation. );
> sub remove_escapes {
> 	local ($line) = @_;
> 	#You can try $line=$QUERY_STRING
> 	#First, change pluses (+) to spaces
> 	$line =~ s/\+/\ /g;
> 	#Then convert %XX values from hex to regular characters
> 	$line =~ s/%(..)pack( c,hex($1)) /ge;
> 	return( $line );
> @name_value_pairs = split( /&/ , $ENV( QUERY_STRING );
> foreach $pair ( @name_value_pairs ) {
> 	($name,$value) = split( /=/,pair );
> require cgi-lib.pl;
> &ReadParse;
> <P>
> Your First Name : <INPUT TYPE= TEXT NAME= USERNAME>
> <P>
> Print Thank you, $in{ first_name }, for submitting your comments. ;
> print <<EOF;
> Content-type: text/html
> 
> Marc
> 


-- 
  PLEASE read the Red Hat FAQ, Tips, Errata and the MAILING LIST ARCHIVES!
		http://www.redhat.com http://archive.redhat.com
         To unsubscribe: mail redhat-list-request@redhat.com with 
                       "unsubscribe" as the Subject.


home help back first fref pref prev next nref lref last post