Re: [PHP] Proper OOP Syntax

2006-02-21 Thread Richard Lynch
On Mon, February 20, 2006 5:25 pm, Albert Padley wrote:
> $password = (strlen($this->user_pw) < 32) ? md5($this->user_pw) :
> $this->user_pw;

So, if I use a password with more than 32 characters, you're NOT going
to md5() it?!

This is not really the Right Way to do this, imho.

>   $sql = sprintf("SELECT COUNT(*) AS test, TeamID FROM %s 
> WHERE
> BINARY login = '%s' AND pw = '%s' AND active = 'y'", $this-
>  >table_name, $this->user, $password);
>   }
>   $result = mysql_query($sql) or die(mysql_error());

list($text, $TeamID) = mysql_fetch_row($result);

session_start();
$_SESSION['TeamID'] = $TeamID


>   if (mysql_result($result, 0, "test") == 1) {
>   return true;
>   } else {
>   return false;
>   }
>
> How would I set a session variable for the value of TeamID?

>
> Thanks.
>
> Albert Padley
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Proper OOP Syntax

2006-02-20 Thread Albert Padley

Thank you Chris.

Albert


On Feb 20, 2006, at 5:00 PM, Chris wrote:


Albert Padley wrote:

Given the following code:
$password = (strlen($this->user_pw) < 32) ? md5($this->user_pw) :   
$this->user_pw;
$sql = sprintf("SELECT COUNT(*) AS test, TeamID FROM % 
s WHERE  BINARY login = '%s' AND pw = '%s' AND active = 'y'",  
$this-  >table_name, $this->user, $password);

}
$result = mysql_query($sql) or die(mysql_error());
if (mysql_result($result, 0, "test") == 1) {
return true;
} else {
return false;
}
How would I set a session variable for the value of TeamID?


You'll need to change it so you actually fetch the teamid:


$result = mysql_query($sql) or die(mysql_error());

$row = mysql_fetch_assoc($result);
if (empty($row)) {
  return false;
}

$_SESSION['TeamID'] = (int)$row['TeamID'];
return true;


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Proper OOP Syntax

2006-02-20 Thread Chris

Albert Padley wrote:

Given the following code:

$password = (strlen($this->user_pw) < 32) ? md5($this->user_pw) :  
$this->user_pw;
$sql = sprintf("SELECT COUNT(*) AS test, TeamID FROM %s 
WHERE  BINARY login = '%s' AND pw = '%s' AND active = 'y'", $this- 
 >table_name, $this->user, $password);

}
$result = mysql_query($sql) or die(mysql_error());
if (mysql_result($result, 0, "test") == 1) {
return true;
} else {
return false;
}

How would I set a session variable for the value of TeamID?


You'll need to change it so you actually fetch the teamid:


$result = mysql_query($sql) or die(mysql_error());

$row = mysql_fetch_assoc($result);
if (empty($row)) {
  return false;
}

$_SESSION['TeamID'] = (int)$row['TeamID'];
return true;

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Proper OOP Syntax

2006-02-20 Thread Albert Padley

Given the following code:

$password = (strlen($this->user_pw) < 32) ? md5($this->user_pw) :  
$this->user_pw;
			$sql = sprintf("SELECT COUNT(*) AS test, TeamID FROM %s WHERE  
BINARY login = '%s' AND pw = '%s' AND active = 'y'", $this- 
>table_name, $this->user, $password);

}
$result = mysql_query($sql) or die(mysql_error());
if (mysql_result($result, 0, "test") == 1) {
return true;
} else {
return false;
}

How would I set a session variable for the value of TeamID?

Thanks.

Albert Padley

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php