Jump to content

login system


raprap

Recommended Posts

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); } } ?>

Link to comment
Share on other sites

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 by mac_gyver
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.