CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
URL Address info to form

 



Stu
New User

May 15, 2000, 2:14 AM

Post #1 of 2 (548 views)
URL Address info to form Can't Post

I need some help. I need to find a script that will allow somebody to type in whatever they want after the .com/ and then what they type in will be placed in a form to be submitted. It would be used as kind of a "referral" program where a person could link to a site and get credit for telling them about it by placing their name, etc. after the .com/.

Thanks,
Stuart Siegel


Jasmine
Administrator / Moderator

May 19, 2000, 4:16 AM

Post #2 of 2 (548 views)
Re: URL Address info to form [In reply to] Can't Post

Assuming you can run cgi programs outside of your cgi-bin, you can write a program and toss it into your main www directory (we'll worry about making the program the default page in a bit).

Using the $ENV{'QUERY_STRING'}, you can pull information into your script.

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>


#!/usr/bin/perl

my $name = $ENV{'QUERY_STRING'};

print "Content-type: text/html\n\n";
print qq~
<HTML>
<BODY>
Hello $name!
<!-- Whatever html code you want -->
</BODY>
</HTML>~;
</pre><HR></BLOCKQUOTE>

Now, onto making your new program the default page (this assumes you're on an Apache server).

Let's say you name the program index.cgi, which is commonly listed as one of the filenames that a web server will look for as a directory's default page.

If your web server either doesn't look for index.cgi file as a default page, or it doesn't look for index.cgi first, create a file named .htaccess (notice there's nothing in front of the period, and the extension is htaccess) and copy the following line to it:

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>


DirectoryIndex index.cgi index.shtml index.html index.htm
</pre><HR></BLOCKQUOTE>

Because the server will look for indexes in the order they're listed in DirectoryIndex, tt's important that index.cgi is first in the list.

Save the file (if your text editor tacks on a .txt extension, simply rename it to .htaccess) and upload it to your main www directory in ASCII format.

Now you can use whatever.com/?myname because index.cgi is the first page your web server will look for and find when searching for directory index (default) pages.

Hope this helps. Good luck!

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives