Hi monks, I was wondering if someone can help. I am tring to write a script that allows users to log on to my database. However, if a wrong username or password is entered the 'post' method still directs users to the database. I tried to write an if statement as below but this had no effect. Can anyone suggest a solution?? cheers.
if ((!($username eq 'sugar')) && (!($password eq 'spice'))) print "you have entered a wrong password!"; }
the code
#! /usr/bin/perl use strict; use DBI; use CGI qw(:standard); my($cgi); $cgi = new CGI; use CGI::Carp qw(fatalsToBrowser); my ($title) = "DB: Log in"; print $cgi->header (); print $cgi->start_html (-title=>"$title", -BGCOLOR=>"#ccddff", -style=>{'src' =>'style1.css'}); print "<table width=600 bgcolor=ffcc66><tr><td><b><i> DB: Log in</i></ +td></tr></table><p>"; my $username; my $password; print "<FORM METHOD=\"post\" ACTION=\"http://hostname/~user/cgi-bin/da +tabase/homepage.cgi\">"; print "<TABLE><TR VALIGN=\"baseline\"><TD VALIGN=\"baseline\"><h3>Ente +r user name</h3></TD><TD><INPUT TYPE=\"TEXT\" NAME=\"username\" SIZE= +\"10\"></TD></TR><TR VALIGN=\"baseline\"><TD VALIGN=\"baseline\"><h3> +Enter password</h3></TD> <TD><INPUT TYPE=\"password\" NAME=\"password +\" SIZE=\"10\"></TD></TR><TD><INPUT TYPE=\"SUBMIT\" value=\"Log in\"> +</TABLE></FORM>"; $username = param('username'); $password = param('password'); print $cgi->end_html ();

In reply to CGI + password problems by Anonymous Monk

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.