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

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

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


New User

May 15, 2000, 2:14 AM

Post #1 of 2 (771 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/.

Stuart Siegel

Administrator / Moderator

May 19, 2000, 4:16 AM

Post #2 of 2 (771 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>


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

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

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

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 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