[PHP] LogIn check within function within class :: HELP!
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 ""; $this -> DisplayMenu($this->buttons); echo ""; $this -> DisplayFooter(); break; default: echo "This stupid thing STILL Does NOT WORK!"; break; } } function DisplayHeader($title,$employeeid) { echo "\n\n$title"; echo ""; echo "\n\n"; echo ""; echo ""; echo " "; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo "ADMINISTRATOR LOGGED IN: "; echo $employeeid; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; } 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($count>0) { $count = "1"; } else { $count = "0"; } } function DisplayMenu($buttons) { echo ""; echo ""; echo""; $width = 100/count($buttons); while(list($name,$url) = each ($buttons)) { $this ->DisplayButton($width,$name,$url); } echo ""; echo ""; echo ""; } function DisplayButton($width,$name,$url) { echo "$name"; } function DisplayFooter() { ?> } } ?> 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
[PHP] Class Function Problem
I have an admin panel that each section contains a set of tools so on each page I can set $toolsneeded = "admin" or $toolsneeded = "employees"; etc. I keep recieving this error: Warning: Division by zero in /home/www/website/admin/include/adminclass.php on line 250 Warning: Variable passed to each() is not an array or object in /home/www/website/admin/include/adminclass.php on line 251 This is line 250: $height = 100/count($tools); Here is the page that uses the class. SetContent($redux); $toolsneeded = "admin"; $adminroot->SetTools($toolsneeded); $adminroot->Display($employeeid,$password,$title); ?> Here is my class file with some of the functions removed for brevity. I have real problems understanding $this-> so you may find that Im using it in the wrong place or not using it where I should be. "orders_root.php", "products" => "products_root.php" ); ## ##SET FUNCTIONS ## function SetContent($newContent) { $this->content = $newContent; } function SetTools($newTools) { $this->toolsneeded = $newTools; } ## ##DISPLAY FUNCTION ## function Display($employeeid,$password,$title) { session_start(); session_register("employeeid"); $count = $this -> VerifyLogin($employeeid,$password); switch($count) { case "1": $this -> DisplayHeader($title,$employeeid); echo ""; $this -> DisplayMenu($this->buttons); echo ""; $this -> DisplayContent($this->tools,$this->content); echo ""; $this -> DisplayFooter(); break; default: $title = "Please Try Again"; $employeeid = ""; $this -> DisplayHeader($title,$employeeid); echo ""; echo "Your username and password combination is incorrect. Please try again."; $this -> DisplayLogInForm(); echo ""; $this -> DisplayFooter(); break; } } ## ##DISPLAY TOOLS FUNCTION ## function DisplayTools($tools) { echo ""; echo ""; echo""; echo""; ### ###Line 250 ### $height = 100/count($tools); ### ### while(list($name,$url) = each($tools)) { $this ->ToolsLayout($height,$name,$url); } echo ""; echo ""; echo ""; echo ""; } ## ##TOOLS LAYOUT FUNCTION ## function ToolsLayout($height,$name,$url) { echo ""; echo "[ $name ]"; } function ToolSelected($toolsneeded) { switch($toolsneeded) { case "admin": DisplayTools($toolsadmin); break; case "orders": echo "Order Tools"; break; default: echo "Your Tools do not work"; } } ## ##DISPLAY CONTENT FUNCTION ## function DisplayContent($toolsneeded,$content) { ?> DisplayTools($toolsneeded); ?> admin a and i balancing administration http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Cookies Help
Ive created a log in that essentially if the username and password are found in the database it displays one section of code and if its not found it display another log in form Im able to log in and my verifylogin() function works because if the username and password are not found it displays the login form again but when I click a link to another page that uses my admin class it just displays that second log in form as if the username and password are not carrying over I know this has something to do with my session_start or something but I've no idea I'm very new to sessions and cookies: Here is my page admin page display: SetContent($redux); $toolsneeded = "admin"; $adminroot->SetToolsNeeded($toolsneeded); $adminroot->Display($employeeid,$password,$title); ?> Here are the relevant parts of my class file: ## ##CLASS DECLARATION ## class ADMINPAGE { ## ##DISPLAY FUNCTION ## function Display($employeeid,$password,$title) { $count = $this -> VerifyLogin($employeeid,$password); switch($count) { case "1": $this -> DisplayHeader($title,$employeeid); echo ""; $this -> DisplayMenu($this->buttons); echo ""; $this -> DisplayContent($this->toolsneeded,$this->content); echo ""; $this -> DisplayFooter(); break; default: $title = "Please Try Again"; $employeeid = ""; $password = ""; $this -> DisplayHeader($title,$employeeid,$password); echo ""; echo "Your username and password combination is incorrect. Please try again."; $this->DisplayLogInForm(); echo ""; $this -> DisplayFooter(); break; } } ## ##VERIFY LOGIN FUNCTION ## function VerifyLogin($employeeid,$password) { 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($count>0) { $count = "1"; } else { $count = "0"; } return $count; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php