#!/usr/bin/perl -wT use strict; use CGI; my $query = new CGI; my $datafile = "/home/sites/www.yourname.com/users/web/mysites.txt"; use vars qw($title $location $name $url); ############ THE ACTUAL PROGRAM ############ # regex should only allow characters that you # know are acceptable. In this case a-z, A-Z, _, 0-9 # The way we're assigning $1 to $name is called "taint checking" if ($query->param('name') =~ /^(\w+)$/) { $name = $1; } else { # If we got here, there were illegal characters entered (or no character) &incomplete; } $url = &findurl; if ($url) { # Send 'em where they want to go print $query->redirect($url); } else { # No url, so do something different } ############ FIND URL ############ sub findurl { # always check the return calls on an open open INFO, "<$datafile" or die "Can't open $datafile: $!"; my @information = ; foreach (@information) { ($title, $location) = split /\|/; } if ($title eq $name) { $url = $location; } close (INFO); return $url; } sub incomplete { print $query->header, $query->start_html(-title => "Incomplete", -bgcolor => "white"), $query->h1("Form not complete"), $query->p(), $query->hr(), $query->p("Sorry, you forgot to enter something."), $query->p("Please hit the back button on your browser and try again."), $query->end_html; exit; }