jamesxg1 Posted August 5, 2009 Share Posted August 5, 2009 Hiya peeps, I dont understand what is going on here would someone take a look for me please, <?php session_start(); include '../includes/SuperAdmin.inc'; include '../includes/sessionfunctions.inc'; $add = new SuperAdmin(); $add->MYSQLConnection(); $list = $add->SuperAdminListUsers(); $session = new SessionFunctions(); $session->SuperAdminSessionVerification(); $session->SuperAdminSessionSecurity(); $session->SuperAdminSessionRegen(); $getvar = trim($_GET['do']); switch ($getvar) { case "del": $add->SuperAdminUserDelete($_GET['username'], $_GET['id']); break; case "sus": $add->SuperAdminUserSuspend($_GET['username'], $_GET['id']); break; case "unsus": $add->SuperAdminUserUnSuspend($_GET['username'], $_GET['id']); break; case "edit": $edituser = $add->SuperAdminEditUserInfo($_GET['username'], $_GET['id']); break; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>Admin</title> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <link rel="stylesheet" type="text/css" href="../core/css/admin.css" media="all"> </head> <body> <div id="main"> <div id="header"> <a href="index.html" class="logo"><img src="../images/logo.gif" width="101" height="29" alt="" /></a> <ul id="top-navigation"> <li class="active"><span><span>Administrator</span></span></li> </ul> </div> <div id="middle"> <div id="left-column"> <h3>Control Panel</h3> <ul class="nav"> <li><a href="#">Mail (NUM)</a></li> <li><a href="#">Q & A's</a></li> <li><a href="#">Complaints (NUM)</a></li> <li><a href="#">Ipsum dollar</a></li> <li><a href="#">Lorem Ipsum dollar</a></li> <li class="last"><a href="#">Dollar Lorem Ipsum</a></li> </ul> <a href="#" class="link">Link here</a> <a href="#" class="link">Link here</a> </div> <div id="center-column"> <div class="top-bar"> <a href="addnewmem.php" class="button">Add New</a> <h1>Welcome</h1> <div class="breadcrumbs"><a href="#">Homepage</a> / <a href="#">Managment</a></div> </div><br /> <div class="select-bar"> <label> <input type="text" name="textfield" /> </label> <label> <input type="submit" name="Submit" value="Search" /> </label> </div> <div class="table"> <img src="../images/bg-th-left.gif" width="8" height="7" alt="" class="left" /> <img src="../images/bg-th-right.gif" width="7" height="7" alt="" class="right" /> <table class="listing" cellpadding="0" cellspacing="0"> <tr> <th class="first" width="177">Client</th> <th>Suspend</th> <th>Delete</th> <th>Un-Suspend</th> <th class="last">Edit</th> </tr> <tr> <?php while($row = mysql_fetch_array($list, MYSQL_ASSOC)) { echo '<td class="first style1">' . $row['firstname'] . "\n"; echo $row['lastname']; echo ' (' . $row['sus'] . ')</td>'; echo '<td><a href="admin_home.php?do=sus&username=' . $row['username'] . '&id=' . $row['id'] . '"><img src="../images/application_error.png" width="16" height="16" alt="" /></a></td>'; echo '<td><a href="admin_home.php?do=del&username=' . $row['username'] . '&id=' . $row['id'] . '"><img src="../images/application_delete.png" width="16" height="16" alt="" /></a></td>'; echo '<td><a href="admin_home.php?do=unsus&username=' . $row['username'] . '&id=' . $row['id'] . '"><img src="../images/application_key.png" width="16" height="16" alt="" /></a></td>'; echo '<td class="last"><a href="admin_home.php?do=edit&username=' . $row['username'] . '&id=' . $row['id'] . '"><img src="../images/note_edit.png" width="16" height="16" alt="add" /></a></td></tr>'; } ?> </table> <div class="select"> <strong>Other Pages: </strong> <select> <option>1</option> </select> </div> </div> <div class="table"> <img src="../images/bg-th-left.gif" width="8" height="7" alt="" class="left" /> <img src="../images/bg-th-right.gif" width="7" height="7" alt="" class="right" /> <table class="listing form" cellpadding="0" cellspacing="0"> <tr> <th class="full" colspan="2">Header Here</th> </tr> <?php while($row = mysql_fetch_array($edituser, MYSQL_ASSOC)) { echo <<<EOF <tr><td class="first" width="172"><strong>Lorem Ipsum</strong></td> <td class="last"><input type="text" class="text" /></td></tr><tr class="bg"> <td class="first"><strong>Lorem Ipsum</strong></td> <td class="last"><input type="text" class="text" /></td> </tr><tr><td class="first""><strong>Lorem Ipsum</strong></td> <td class="last"><input type="text" class="text" /></td></tr> <tr class="bg"><td class="first"><strong>Lorem Ipsum</strong></td> <td class="last"><input type="text" class="text" /></td></tr> EOF; } ?> </table> <p> </p> </div> </div> <div id="right-column"> <strong class="h">INFO</strong> <div class="box">Detect and eliminate viruses and Trojan horses, even new and unknown ones. Detect and eliminate viruses and Trojan horses, even new and </div> </div> </div> <div id="footer"></div> </div> </body> </html> <?php class SuperAdmin { private $dbusername; private $dbpassword; private $dbhost; private $dbbase; private $samsender; private $samreason; private $samesubject; private $samtouser; private $samtodo; private $samudusername; private $samudid; private $saususername; private $sausid; private $sauususername; private $sauusid; private $sauafirstname; private $saualastname; private $sauausername; private $sauapassword; private $sauaemail; private $sauaphone; private $sauaaddress; private $sauaaddresstwo; private $sauacity; private $sauacounty; private $sauapostcode; private $lusername; private $lpassword; private $lsession; private $urusername; private $urid; function __construct() { $this->randid = mt_rand(); } function MYSQLConnection($dbusername = "root", $dbpassword = "", $dbhost = "localhost", $dbbase = "sli") { $this->dbusername = $dbusername; $this->dbpassword = $dbpassword; $this->dbhost = $dbhost; $this->dbbase = $dbbase; $this->MYSQLConnect = mysql_connect($this->dbhost, $this->dbusername, $this->dbpassword); $this->SelectDB = mysql_select_db($this->dbbase, $this->MYSQLConnect) or die(mysql_error()); return($this->SelectDB); } function SuperAdminMail($samsender, $samreason, $samsubject, $samtouser, $samtodo) { $this->msender = $samsender; $this->mreason = $samreason; $this->msubject = $samsubject; $this->mwho = $samtouser; $this->mwhat = $samtodo; } function SuperAdminUserDelete($samudusername, $samudid) { $this->delusername = mysql_real_escape_string($samudusername); $this->delid = mysql_real_escape_string($samudid); mysql_query("DELETE FROM `members` WHERE username = '$this->delusername' AND id = '$this->delid' LIMIT 1") or die(mysql_error()); $donedel = "The user $this->delusername was removed from the database"; header('Location: admin_home.php'); return $donedel; } function SuperAdminUserSuspend($saususername, $sausid) { $this->sususername = mysql_real_escape_string($saususername); $this->susid = mysql_real_escape_string($sausid); mysql_query("UPDATE `members` SET sus = '1' WHERE username = '$this->sususername' AND id = '$this->susid' LIMIT 1") or die(mysql_error()); $donesus = "The user $this->sususername was suspended from the site."; header('Location: admin_home.php'); return $donesus; } function SuperAdminUserUnSuspend($sauususername, $sauusid) { $this->usususername = mysql_real_escape_string($sauususername); $this->ususid = mysql_real_escape_string($sauusid); mysql_query("UPDATE `members` SET sus = '0' WHERE username = '$this->usususername' AND id = '$this->ususid' LIMIT 1") or die(mysql_error()); $doneusus = "The user $this->usususername was suspended from the site."; header('Location: admin_home.php'); return $doneusus; } function SuperAdminPassGen($length = "20", $strength = "8") { $vowels = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz123456789'; $consonants = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz123456789'; if ($strength & 1) { $consonants .= 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz123456789'; } if ($strength & 2) { $vowels .= "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz123456789"; } if ($strength & 4) { $consonants .= 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz123456789'; } if ($strength & { $consonants .= '@#$%'; } $password = ''; $alt = time() % 2; for ($i = 0; $i < $length; $i++) { if ($alt == 1) { $password .= $consonants[(rand() % strlen($consonants))]; $alt = 0; } else { $this->genpass .= $vowels[(rand() % strlen($vowels))]; $alt = 1; } } return ($this->genpass); } function SuperAdminUserAdd($sauafirstname, $saualastname, $sauausername, $sauapassword, $sauaemail, $sauaphone, $sauaaddress, $sauaaddresstwo, $sauacity, $sauacounty, $sauapostcode, $sauacountry) { $this->afirstname = mysql_real_escape_string($sauafirstname); $this->alastname = mysql_real_escape_string($saualastname); $this->ausername = mysql_real_escape_string($sauausername); $this->apassword = mysql_real_escape_string(md5($sauapassword)); $this->aapassword = mysql_real_escape_string($sauapassword); $this->aemail = mysql_real_escape_string($sauaemail); $this->aphone = mysql_real_escape_string($sauaphone); $this->aaddress = mysql_real_escape_string($sauaaddress); $this->aaddresstwo = mysql_real_escape_string($sauaaddresstwo); $this->acity = mysql_real_escape_string($sauacity); $this->acounty = mysql_real_escape_string($sauacounty); $this->apostcode = mysql_real_escape_string($sauapostcode); $this->acountry = mysql_real_escape_string($sauacountry); mysql_query("INSERT INTO `members` (id, firstname, lastname, email, phone, address, addresstwo, city, county, postcode, country, username, password, sus) VALUES('$this->randid', '$this->afirstname', '$this->alastname', '$this->aemail', '$this->aphone', '$this->aaddress', '$this->aaddresstwo', '$this->acity', '$this->acounty', '$this->apostcode', '$this->acountry', '$this->ausername', '$this->apassword', '1') LIMIT 1") or die(mysql_error()); $doneadd .= "$this->afirstname $this->alastname was added to the database."; return $doneadd; } function SuperAdminLogin($lusername, $lpassword, $lsession) { session_start(); $this->lusername = mysql_real_escape_string($lusername); $this->lpassword = mysql_real_escape_string(md5($lpassword)); $this->lsession = mysql_real_escape_string(md5($lsession)); $this->LoginQ = "SELECT * FROM `superadmin` WHERE username = '$this->lusername' AND password = '$this->lpassword' AND sessionid = '$this->lsession'"; $this->LoginR = mysql_query($this->LoginQ) or die (mysql_error()); if(mysql_num_rows($this->LoginR) == '1') { while($fetch = mysql_fetch_array($this->LoginR)) { if($fetch['sus'] == '0') { $_SESSION['username'] = $this->lusername; $_SESSION['id'] = $fetch['id']; $_SESSION['sessionid'] = $fetch['sessionid']; header('Location: admin_home.php'); } else { $susp = "Sorry but the account you are trying to access is suspended, Please try again."; return $susp; exit(); } } $exist = "Sorry but the account you are trying to access is non existant, Please try again."; return $exist; } } function SuperAdminLogout() { session_start(); session_unset(); session_destroy(); header('Location: adminlogin.php'); } function SuperAdminListUsers() { $this->ListUsers = mysql_query("SELECT * FROM `members`") or die(mysql_error()); return ($this->ListUsers); } function SuperAdminEditUserInfo($urusername, $urid) { $this->urusername = $urusername; $this->urid = $urid; $this->ListTheUsers = mysql_query("SELECT * FROM `members` WHERE id = '$this->urid' AND username = '$this->urusername'") or die(mysql_error()); return ($this->ListTheUsers); } } ?> Fatal error: Call to undefined method SuperAdmin::SuperAdminEditUserInfo() in C:\xampp\htdocs\project\admin\admin_home.php on line 34 It works fine until i go to the url http://localhost/project/admin/admin_home.php?do=edit&username=jamesxg1&id=2 Many thanks, James. Link to comment https://forums.phpfreaks.com/topic/168920-function-error/ Share on other sites More sharing options...
tobimichigan Posted August 5, 2009 Share Posted August 5, 2009 Mr James, quite some work u've got there..I suppose u must have invested a lot of energy into these.. Anyways, I'd suggest step by step debugging. Try the functions one by one with a return value and see the output..I guess that'd be good for a start . Link to comment https://forums.phpfreaks.com/topic/168920-function-error/#findComment-891205 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.