[PHP] login check

2005-08-05 Thread sub
 
I think this is the way I need to write my if statement. 

if ( $min  $user[ min ] == $min  $user[ pin ] == $pin || $pin == 
'allow')

$min login name entered by the customer at the form. 
$user[min] is the login name from my sql db that matches $min
$user[pin] is the password from mysql db that matches $min
$pin is the password that is entered by the user

There's 4 checks
1) $min must have a value
2)  $user[ min ] must equal $min 
3) $user[ pin ] must equal $pin 
4) $pin == 'allow'

I want it so that both 1 and 2 must be true and either 3 or 4 must be true. 
Will this if statement work?


Andrew Darrow
Kronos1 Productions
www.pudlz.com



Re: [PHP] login check

2005-08-05 Thread Jochem Maas

[EMAIL PROTECTED] wrote:
 
I think this is the way I need to write my if statement. 


if ( $min  $user[ min ] == $min  $user[ pin ] == $pin || $pin == 
'allow')


try a couple paretheses to make your intension explicit. your if statement might
work the way you want it but I have no idea - and I'm way to lazy to go and look
up the operator precedence to work it out

if ($min  $user[ min ] == $min  ($user[ pin ] == $pin || $pin == 
'allow')) {
// you are okay to login
}



$min login name entered by the customer at the form. 
$user[min] is the login name from my sql db that matches $min

$user[pin] is the password from mysql db that matches $min
$pin is the password that is entered by the user

There's 4 checks
1) $min must have a value
2)  $user[ min ] must equal $min 
3) $user[ pin ] must equal $pin 
4) $pin == 'allow'


check 4 seems a little absurd - anyone who knows it will be able to login
as anyone on your app. also checking whether $user['min'] is equal to $min
_seems_ pointless because I assume that you had to extract the data from the
database somehow - usually this means using the login (i.e. $min) entered by
the user to do the look up.

lots of good reading here on security: http://www.phpsec.org/



I want it so that both 1 and 2 must be true and either 3 or 4 must be true. 
Will this if statement work?


Andrew Darrow
Kronos1 Productions
www.pudlz.com




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



[PHP] LogIn check within function within class :: HELP!

2002-12-08 Thread Sean Mayhew
Im just about at wits end here Im trying to verify that a users ID and 
Password exist in the MySQL Database and then if it does display certain 
content and if it does not display login form content.

###At present here is the error I'm recieving:
Warning: Missing argument 3 for verifylogin() in 
/home/www/websitename/admin/include/adminclass.inc on line 78
This stupid thing STILL Does NOT WORK!

Here is my class FILE
?
class ADMINPAGE
{
   //class adminpage's attributes
var $title = 75;
var $content;
var $buttons = array([ admin ] = admin_root.php,
[ orders ] = orders_root.php,
[ customers ] = customers_root.php,
[ products ] = products_root.php,
[ categories ] = categories_root.php,
[ manufacturers ] = manufacturers_root.php,
[ vehicles ] = vehicles_root.php);
var $count;


function SetTitle($newTitle)
   {
   $this-title = $newTitle;
   }

function SetContent($newContent)
   {
   $this-content = $newContent;
   }

function SetButtons($newbuttons)
   {
   $this-buttons = $newbuttons;
   }

function Display($employeeid,$password,$title,$count)
   {
   session_start();
   session_register(employeeid);
   $this - VerifyLogin($employeeid,$password);
   switch($count)
   {
   case 1:
   $this - DisplayHeader($title,$employeeid);
   echo centerbr;
   $this - DisplayMenu($this-buttons);
   echo /centerbr;
   $this - DisplayFooter();
   break;
   default:
   echo This stupid thing STILL Does NOT WORK!;
   break;
   }
   }

function DisplayHeader($title,$employeeid)
   {

   echo html\nhead\ntitle$title/title;
   echo link href='/aistyles.css' rel='stylesheet' type='text/css';
   echo /head\nbody leftmargin='0' topmargin='0' marginwidth='0' 
marginheight='0' \n;
   echo table width='100%'  border='0' cellspacing='0' 
cellpadding='0';
 echo tr;
  echo td bgcolor='#FF6600' div align='left'img 
src='/images/designelements/logo.gif' width='348' height='35'/div/td;
 echo /tr;
echo tr;
   echo td bgcolor='#00';
   echo table width='100%'  border='0' cellspacing='0' 
cellpadding='0';
   echo tr;
   echo tdimg src='/images/designelements/spacer.gif' width='5' 
height='15'/span/td;
   echo tdspan class='admin_header'ADMINISTRATOR LOGGED 
IN:nbsp;nbsp;;
   echo $employeeid;
   echo /span/div;
 echo /td;
   echo /tr;
 echo /table;
   echo /td;
 echo /tr;
   echo /table;
   }

function VerifyLogin($employeeid,$password,$count)
   {
   include('dbconnection.php');
   $employeequery = Select count(*) from employees where employeeid = 
'$employeeid' and password='$password';
   $employeeresult = mysql_query($employeequery);
   if(!$employeeresult)
   {
   echo 'Please Try Again Later.';
   exit();
   }
   $count = mysql_result($employeeresult,0,0);
   if($count0)
   {
   $count = 1;
   }
   else
   {
   $count = 0;
   }
   }

function DisplayMenu($buttons)
   {
   echo table width = \500\ bgcolor=\#00\ cellpadding=\1\ 
cellspacing=\0\trtd;
   echo table width=\100%\ bgcolor=\#ff6600\ cellpadding=\1\ 
cellspacing=\0\trtd;
   echodiv align=centertable width=\100%\ bgcolor=\#ff\ 
cellpadding=\5\ cellspacing=\0\trtd;
   $width = 100/count($buttons);
   while(list($name,$url) = each ($buttons))
   {
   $this -DisplayButton($width,$name,$url);
   }
   echo /td/tr/table/div;
   echo /td/tr/table;
   echo /td/tr/table;
   }

function DisplayButton($width,$name,$url)
   {
   echo td width =\$width%\a href = \$url\span class = 
small$name/span/a/td;
   }


function DisplayFooter()
   {
   ?
   table width=100% height=100%  border=0 cellpadding=0 
cellspacing=0
 tr
   td valign=top bgcolor=#00img src=/images/spacer.gif 
width=1 height=300/td
 /tr
/table
/body/html
   ?
   }
}
?




Here is sample page usage of class file

?
require (include/adminclass.inc);
$test = new adminpage();
$title = This is a Nice Page;
$content = Some Temporary Content;
$test -SetContent($content);
$test -Display($employeeid,$password,$title,$count);

?




_
MSN 8 with e-mail virus protection service: 2 months FREE* 
http://join.msn.com/?page=features/virus


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



Re: [PHP] LogIn check within function within class :: HELP!

2002-12-08 Thread Tom Rogers
Hi,

Monday, December 9, 2002, 2:24:47 AM, you wrote:
SM Im just about at wits end here Im trying to verify that a users ID and 
SM Password exist in the MySQL Database and then if it does display certain 
SM content and if it does not display login form content.

SM ###At present here is the error I'm recieving:
SM Warning: Missing argument 3 for verifylogin() in 
SM /home/www/websitename/admin/include/adminclass.inc on line 78
SM This stupid thing STILL Does NOT WORK!

SM Here is my class FILE
SM ?
SM class ADMINPAGE
SM {
SM //class adminpage's attributes
SM var $title = 75;
SM var $content;
SM var $buttons = array([ admin ] = admin_root.php,
SM  [ orders ] = orders_root.php,
SM  [ customers ] = customers_root.php,
SM  [ products ] = products_root.php,
SM  [ categories ] = categories_root.php,
SM  [ manufacturers ] = manufacturers_root.php,
SM  [ vehicles ] = vehicles_root.php);
SM var $count;


SM function SetTitle($newTitle)
SM {
SM $this-title = $newTitle;
SM }

SM function SetContent($newContent)
SM {
SM $this-content = $newContent;
SM }

SM function SetButtons($newbuttons)
SM {
SM $this-buttons = $newbuttons;
SM }

SM function Display($employeeid,$password,$title,$count)
SM {
SM session_start();
SM session_register(employeeid);
SM $this - VerifyLogin($employeeid,$password);
SM switch($count)
SM {
SM case 1:
SM $this - DisplayHeader($title,$employeeid);
SM echo centerbr;
SM $this - DisplayMenu($this-buttons);
SM echo /centerbr;
SM $this - DisplayFooter();
SM break;
SM default:
SM echo This stupid thing STILL Does NOT WORK!;
SM break;
SM }
SM }

SM function DisplayHeader($title,$employeeid)
SM {

SM echo html\nhead\ntitle$title/title;
SM echo link href='/aistyles.css' rel='stylesheet' type='text/css';
SM echo /head\nbody leftmargin='0' topmargin='0' marginwidth='0' 
marginheight='0' \n;
SM echo table width='100%'  border='0' cellspacing='0' 
cellpadding='0';
SM   echo tr;
SMecho td bgcolor='#FF6600' div align='left'img 
SM src='/images/designelements/logo.gif' width='348' height='35'/div/td;
SM   echo /tr;
SM  echo tr;
SM echo td bgcolor='#00';
SM echo table width='100%'  border='0' cellspacing='0' 
cellpadding='0';
SM echo tr;
SM echo tdimg src='/images/designelements/spacer.gif' width='5' 
height='15'/span/td;
SM echo tdspan class='admin_header'ADMINISTRATOR LOGGED 
SM IN:nbsp;nbsp;;
SM echo $employeeid;
SM echo /span/div;
SM   echo /td;
SM echo /tr;
SM   echo /table;
SM echo /td;
SM   echo /tr;
SM echo /table;
SM }

SM function VerifyLogin($employeeid,$password,$count)
SM {
SM include('dbconnection.php');
SM $employeequery = Select count(*) from employees where employeeid = 
SM '$employeeid' and password='$password';
SM $employeeresult = mysql_query($employeequery);
SM if(!$employeeresult)
SM {
SM echo 'Please Try Again Later.';
SM exit();
SM }
SM $count = mysql_result($employeeresult,0,0);
SM if($count0)
SM {
SM $count = 1;
SM }
SM else
SM {
SM $count = 0;
SM }
SM }

SM function DisplayMenu($buttons)
SM {
SM echo table width = \500\ bgcolor=\#00\ cellpadding=\1\ 
cellspacing=\0\trtd;
SM echo table width=\100%\ bgcolor=\#ff6600\ cellpadding=\1\ 
cellspacing=\0\trtd;
SM echodiv align=centertable width=\100%\ bgcolor=\#ff\ 
SM cellpadding=\5\ cellspacing=\0\trtd;
SM $width = 100/count($buttons);
SM while(list($name,$url) = each ($buttons))
SM {
SM $this -DisplayButton($width,$name,$url);
SM }
SM echo /td/tr/table/div;
SM echo /td/tr/table;
SM echo /td/tr/table;
SM }

SM function DisplayButton($width,$name,$url)
SM {
SM echo td width =\$width%\a href = \$url\span class = 
small$name/span/a/td;
SM }


SM function DisplayFooter()
SM {
SM ?
SM table width=100% height=100%  border=0 cellpadding=0 
cellspacing=0
SM   tr
SM td valign=top bgcolor=#00img src=/images/spacer.gif 
SM width=1 height=300/td
SM   /tr
SM /table
SM /body/html
SM ?
SM }
SM }
?




SM Here is sample page usage of class file

SM ?
SM require (include/adminclass.inc);
SM $test = new adminpage();
SM $title = This is a Nice Page;
SM $content = Some Temporary Content;
$test -SetContent($content);
$test -Display($employeeid,$password,$title,$count);

?




SM _
SM MSN 8