Ok, this is the most confusing script I've ever worked with.
I have no problem getting it to work.....the problem is that I don't know why it's working.....It shouldn't work....
and some of the variables aren't even defined unless I'm using globals I guess
Well anyway let me explain
Here is the link to the full script I've been editing and using if you want to look at it
www.dockterz.com/party/oldlogin.phpsAlright.....
What I understand of this script is
It first checks to see if you are logging out or not..and logs you out
Then it checks to see if you just came from the login form.....and if you did.....check the login information
Then it has the set of form templates to display at specific times.
On the check login part is where I have the problem/confusion
Right here starting at line 20 it says
[PHP Code]
$user_data = mysql_num_rows($result);
if ($user_data != 0) {
setcookie ("user", md5($user_data[user]));
setcookie ("pass", md5($user_data[pass]));
header("Location: $_SERVER[PHP_SELF]");
} else {
$login_error = true; }
It sets a cookie for what it recieves for a num_rows query. And not only that, it pretends that it's an array when it's not.
What I've been trying to do is this.
[PHP Code]
$num = mysql_num_rows($result);
$user_data = mysql_num_rows($result);
if ($num != 0) {
setcookie ("user", md5($user_data[user]));
setcookie ("pass", md5($user_data[pass]));
header("Location: $_SERVER[PHP_SELF]");
} else {
$login_error = true; }
but it doesn't work for some reason
On Line 45 it compares what I typed in the login form to the cookie....but the odd thing is.......It says....if the Cookie....which has a value of nothing equals the value of what they put for username....then let them pass
And it works....WTF?!?!
it doesn't take a genious to know that username != ""
[PHP Code]
} elseif ($_COOKIE[user] == md5($_POST[username]) && $_COOKIE[pass] == md5($_POST[password])) {
Can anyone make heads or tails of this....because I'm lost....
Here's the link below to see this script in action
www.dockterz.com/party/post.phpthe username is : user
and the password is : pass
Start Free Trial