| Nurchi BECHED 2004-03-28, 10:13 pm |
| Hello, All!
I just had a question.
I have the following piece of code at the "end" of the message.php file:
$ver=verify();
switch ($ver)
{
case 2:
open_write($msgfile, $msgtxt, "\n", "\n <i><b>-".$usrname."</b></i>\n");
$prefmsg=
"Your message has been added to exec message file<br>";
$usermsg=
htmloutput(open_read($msgfile));
break;
case 1:
$prefmsg=
"Wrong password.<br>".
"Your message has <B>NOT</B> been added<br><br>";
break;
case 0:
open_write($guestmsgfile, $msgtxt, "\n", "\n
<i><b>-".$usrname."</b></i>\n");
$prefmsg=
"Your message has been added to a guest file<br>";
$guestmsg=
htmloutput(open_read($guestmsgfile));
break;
case -1:
$prefmsg=
"Your message has <b>NOT</b> been added<br>".
"You most likely have empty username<br>";
break;
case -2:
$prefmsg=
"";
break;
default:
$prefmsg=
"Sorry, something went wrong.<br>Please try again.<br>";
}
verify() is a function that verifies username and if he/she exists and
password is correct, returns 2,
if user doesn't exist and/or password is empty, then it returns 0 (for
guest), if user exists and
password is incorrect, then it returns 1 (wrong password), -1 just means
empty username, and
-2 is some unknown error.
If the user exists+password is correct, it adds and shows message rightaway,
if the message was added to a guest file, then it is added, but shows only
with next load of page.
What am I doing wrong?
Thanks
With best regards, Nurchi BECHED.
P.S.
C makes it easy to shoot yourself in the foot;
C++ makes it harder, but when you do,
it blows away your whole leg."
--Bjarne Stroustrup
|