r_mehmed has asked for the wisdom of the Perl Monks concerning the following question:
until here it works fine, however once one of the buttons of the menu sub is pressed it always prints the error page. i guess what i am unclear is, if i should check for valid user with every subroutine. i also tried to check if the cookies equal the username and password passed from the login form, the result seems to be the same! this is the sub that gets called when a button in sub la_menu is pressed:sub login { my $username = $q->param('username'); my $password = $q->param('password'); my $SQL = "SELECT username, password FROM user WHERE username = + '$username'"; my @row; @row = $dbh->selectrow_array($SQL); unless (exists $row[0]) { &error_page; exit; } unless ($password eq "$row[1]") { error_page(); } la_menu(); }#end#of#sub#login sub error_page { print $q->start_html(-title=>"some.com| ERROR", -style=>{src=>" +../../mycss.css"}); print<<HTML; <p class="edit_header"><strong>some.com | ERROR</strong></p> <h2 class="error">Invalid username or password</h2> <p class="footer"><a href="http://www.some.com">some.com</a></p> HTML } #end#of#sub#error_page sub la_menu { if ($q->param( "add" )) { add_new(); } elsif ($q->param( "edit" )) { edit(); } print<<HTML; <form method="get" name="la_manu" class="edit"> <input name="edit" type="submit" value="Edit Properties " class="b +uttons"> <input name="add" type="submit" value="Add New" class="buttons"> </form> HTML }#end#of#sub#la_menu
hope this is clear?! thankssub add_new { my $user = $q->cookie('username'); my $pass = $q->cookie('password'); if ($cookie eq $user, $cookie1 eq $pass) { print<<HTML; ... HTML }else { error_page(); } }
Edited 2003-03-05 by mirod: changed the title
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: cookies
by dws (Chancellor) on Mar 05, 2003 at 07:10 UTC | |
by perlguy (Deacon) on Mar 05, 2003 at 17:01 UTC | |
|
Re: cookies
by OM_Zen (Scribe) on Mar 05, 2003 at 05:38 UTC |