raprap Posted December 21, 2015 Share Posted December 21, 2015 im new to php and i found a log in system but when i log in i get this error on the page: =") == 1) error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED); else error_reporting(E_ALL & ~E_NOTICE); // initialization of login system and generation code $oSimpleLoginSystem = new SimpleLoginSystem(); echo $oSimpleLoginSystem->getLoginBox(); require_once('footer.php'); // class SimpleLoginSystem class SimpleLoginSystem { // variables var $aExistedMembers; // Existed members array // constructor function SimpleLoginSystem() { $this->aExistedMembers = array( 'User1' => 'd8578edf8458ce06fbc5bb76a58c5ca4', //Sample: MD5('qwerty') 'User2' => 'd8578edf8458ce06fbc5bb76a58c5ca4' ); } function getLoginBox() { ob_start(); require_once('login_form.html'); $sLoginForm = ob_get_clean(); $sLogoutForm = 'logout'; if ((int)$_REQUEST['logout'] == 1) { if (isset($_COOKIE['member_name']) && isset($_COOKIE['member_pass'])) $this->simple_logout(); } if ($_REQUEST['username'] && $_REQUEST['password']) { if ($this->check_login($_REQUEST['username'], MD5($_REQUEST['password']))) { $this->simple_login($_REQUEST['username'], $_REQUEST['password']); return 'Hello ' . $_REQUEST['username'] . '! ' . $sLogoutForm; } else { return 'Username or Password is incorrect' . $sLoginForm; } } else { if ($_COOKIE['member_name'] && $_COOKIE['member_pass']) { if ($this->check_login($_COOKIE['member_name'], $_COOKIE['member_pass'])) { return 'Hello ' . $_COOKIE['member_name'] . '! ' . $sLogoutForm; } } return $sLoginForm; } } function simple_login($sName, $sPass) { $this->simple_logout(); $sMd5Password = MD5($sPass); $iCookieTime = time() + 24*60*60*30; setcookie("member_name", $sName, $iCookieTime, '/'); $_COOKIE['member_name'] = $sName; setcookie("member_pass", $sMd5Password, $iCookieTime, '/'); $_COOKIE['member_pass'] = $sMd5Password; } function simple_logout() { setcookie('member_name', '', time() - 96 * 3600, '/'); setcookie('member_pass', '', time() - 96 * 3600, '/'); unset($_COOKIE['member_name']); unset($_COOKIE['member_pass']); } function check_login($sName, $sPass) { return ($this->aExistedMembers[$sName] == $sPass); } } ?> Quote Link to comment Share on other sites More sharing options...
benanamen Posted December 21, 2015 Share Posted December 21, 2015 (edited) Is the file named with a .php extension and are you running it on a web server with Php installed? The fact that the code is using MD5 tells me your code is way outdated. You shouldn't be using this. Edited December 21, 2015 by benanamen Quote Link to comment Share on other sites More sharing options...
raprap Posted December 21, 2015 Author Share Posted December 21, 2015 okay do you have some place where i can learn to make a login system in php? Quote Link to comment Share on other sites More sharing options...
ginerjm Posted December 21, 2015 Share Posted December 21, 2015 When you post your next set of code, kindly make it more readable. NOBODY codes without breaking it into separate lines. Quote Link to comment Share on other sites More sharing options...
raprap Posted December 21, 2015 Author Share Posted December 21, 2015 its not the code its the error it comes with i always breaks my codes to separate line Quote Link to comment Share on other sites More sharing options...
ginerjm Posted December 21, 2015 Share Posted December 21, 2015 The code you posted above is a blob of unreadable code. Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted December 21, 2015 Share Posted December 21, 2015 (edited) that's not an 'error'. it's the raw php code. if the raw php code is being output to the browser, either - 1) you didn't use a URL when you requested the page and you ended up requesting the file through the file system. 2) the code doesn't start with a full opening php tag - <?php 3) the file extension isn't .php 4) you don't have php installed and working on your web server. Edited December 21, 2015 by mac_gyver Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.