Your code syntax checks out OK but there are lots of errors, many in the HTML.
This code @rqstedtd = split(/&/, $rqst, 2); limits the split to 2 so $rqstedtd[3] is undefined.
This rewrite is untested but might help you a bit. Using CGI.pm makes life a lot easier !
use strict; use warnings; use CGI; my $q = new CGI; my $user = $q->param('user'); my $password = $q->param('password'); # authenticate my ($title,$body); if ( &auth_user($user,$password) eq "OK" ){ ($title,$body) = &validUser(); } else { ($title,$body) = &invalidUser(); }; # print html page print qq(Content-type: text/html\n <html> <head><title>$title</title></head> $body </html>); # # == end of main program # # # authenticate user/passwords # sub auth_user{ my ($user,$password) = @_; open(PASS, "pass") or die "Couldn't find password file.\n"; while(<PASS>){ chomp; my ($u,$p) = split(/\t/, $_, 2); if ( ($u eq $user) && ($p eq $password) ){ close PASS; return "OK"; } } close PASS; return "notOK"; } # valid sub validUser { my $title = "Login successful !"; my $body = q(<body bgcolor="black" text="red"> <h3>Login succesful!</h3><br><br> <a href="www.eircom.net"><h2>Click here to continue</h2></a><hr> </body>); return ($title,$body); } # invalid sub invalidUser { my $title = "Login unsuccessful !"; my $body = q(<body bgcolor="black" text="red"> Invalid username\password.<br> Please try again.<br><br><hr> <form method=POST action="file://C:\perl\login\password\login.cgi"> User Name: <input name="user" size="30"><br> Password: <input name="pass" size="30"><br> <input type="submit" value="Send"></form><hr> </body>); return ($title,$body); }
poj

In reply to Re: Problem with CGI script by poj
in thread Problem with CGI script by eoin

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.