I write this script for my member area (login system)
but don't work all script. Please test the script and
tell me where is the problem. Thank you.
#!perl
BEGIN {
$| = 1;
open (STDERR, ">&STDOUT");
print qq~Content-type: text/html\n\n~;
}
use warnings;
use CGI qw(:standard);
use CGI::Cookie;
use CGI;
$user = "test";
$pws = "123456";
$query = CGI->new();
if ($query->param('user') eq ""){
print "<font color=\"red\">Enter your User name.</font>";
exit;
}
if ($query->param('pws') eq ""){
print "<font color=\"red\">Enter your password.</font>";
exit;
}
if (($query->param('user') eq "$user") && ($query->param('pws') eq "$p
+ws")) {
$query = CGI->new();
my %cookie = CGI::Cookie->fetch;
if (exists $cookie{'$user'}) {
print header,
start_html('got cookie'),
p('found the cookie: ' . $cookie{$user}->value),
end_html,
;
exit;
}
else {
my $cookie = CGI::Cookie->new(-name=>$user,-value=>$pws,-expires=>'
++23h');
print header(-cookie=>$cookie),
start_html('need cookie'),
p('setting cookie, please reload'),
end_html,
;
exit;
}
}
print "Your User name / Password it's not good.<br>";
exit;
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.