Hi,
I am writing a simple script for user login. When there is username entered that is not in database, how do I get perl to print just one time
print “<p>You are not registered.</p>”;
instead of after each checked database line. I had it placed in “else” statement and it would print as many “You are not registered” lines as there are entries in database.
Here is the part that I am talking about:
open(TEMP,">$tmpfile") || die "Can't create $tmpfile.\n";
foreach $i (@indata)
{
chomp($i);
($username,$password) = split(/\|/,$i);
if ($username eq $in{'oldname'} && $password eq $in{'oldpw'} && $in{
+'delete'} ne "yes")
{
print TEMP "$in{'oldname'}|$in{'newpw1'}\n";
print "<p>Your password has been changed.</p>";
print "<p>Thank you!</p>\n";
}
elsif ($username eq $in{'oldname'} && $password eq $in{'oldpw'} &&
+$in{'delete'} eq "yes")
{
print "<p>Your password has been deleted.</p>\n";
print "<p>Thank you!</p>\n";
}
else
{
print TEMP "$i\n";
}
}
close(TEMP);
Thank you in advance!
Edit, BazB: added code tags
To clarify:
{'oldname'} , {'newpw1'} and {'oldpw'} comes from input form as user is logging in to change the password.
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.