Hello, I am working on a redirection script that will allow the an administrator to enter a specific name with url link into a database. So, it would saved like this:
$name\|$url


The problem that I am running into is on the users side. I want to use a <input type=text value=name>,not a drop-down menu. Here's the problem, when a $name is entered in the box, that is not in the database, I get a "file not found" . I'm trying to figure out how to set up the script so that if the $name is invalid they get a preset error message.

Here's the script I'm working with:
#!/usr/bin/perl $datafile = "/home/sites/www.yourname.com/users/web/mysites.txt"; ############ THE ACTUAL PROGRAM ############ &parse; &incomplete unless $FORM{'name'}; $name = "$FORM{'name'}"; &findurl; &doit; ############ SUBROUTINES ############ sub doit { print ("Location: $url\n"); print ("Content-type: text/html\n\n"); } ############ FIND URL ############ sub findurl { open (INFO, "$datafile"); @information = <INFO>; foreach $information (@information) { ($title, $location) = split(/\|/ , $information); { if ($title eq $name) { $url = $location; } } } close (INFO); } ############ PARSE ############ sub parse { read(STDIN, $input, $ENV{'CONTENT_LENGTH'}); $input = $ENV{'QUERY_STRING'} if $ENV{'QUERY_STRING'}; @pairs = split(/&/, $input); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $FORM{$name} = $value; } } sub incomplete { print "Content-type: text/html\n\n "; print <<"HTML"; <HTML><HEAD><TITLE>Incomplete</TITLE></HEAD> <BODY bgcolor=white> <H1>Form not complete</H1> <p> <hr noshade size=1> <p> Sorry, you forgot to enter something. <a href=\"$ENV{'HTTP_REFERER'}\">You should go back and try again</a>. </BODY> </HTML> HTML exit; }
Any help would be greatly appreciated

In reply to Error 404 fix by koacamper

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.