Jump to content

Recommended Posts

This is a function to check if the username & pass stored in a cookie match the database entry for the account:
[code]
function auth()
{
$decryptedpass=decrypt($uname,$loginhash);
$sqlauth="SELECT * FROM users WHERE user_pass='$loginhash'";
$resultauth=mysql_query($sqlauth);
echo $uname;
if (@mysql_num_rows($resultauth)==0)
  {
   return false;
  }
if (@mysql_num_rows($resultauth)>0)
  {
   return true;
  }
}

 

That is an included file. In the main file, index.php, I have this:

 

if (!auth())

{

echo "You are not logged in";

}

if (auth())

{

echo "You are logged in";

}

[/code]

 

It ALWAYS tells me I am not logged in, even though later in the file I exho $uname and $loginhash and they are both displayed correctly, and matching their respective DB fields...

 

Can anyone shed some light on this?

Uhm PHP can handle OOP. None of that sentence makes sense.

 

You need to either pass the variables as arguments or make them global.

 

sorry ok

php is not OOP but can handle OOP

2nd GET, POST, SESSION are global variables so they dont need to be declared as global and can be called any where

 

 

sorry for bad English  ;D ;D ;D

yah but look carefully the function this only need one value which is the $UNAME RIGHT?

wich i believe from a post data so i guess no need to add a parameter

 

and wait what are this line for

$decryptedpass=decrypt($uname,$loginhash);

 

function ends without using this $decryptedpass

LOL weird

 

 

This is a function to check if the username & pass stored in a cookie match the database entry for the account.

 

teng84, we're talking about cookies :)

 

Obviously the function needs arguments:

 

function auth($uname){
$decryptedpass=decrypt($uname,$loginhash);
//rest of code
}
auth($_COOKIE['username']);

 

Smth like that. Is there a decrypt() function in php as i cant find it in the manual? Probably its a custom one.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.