Prev | Current Page 388 | Next

Emilian Balanescu and Cristian Darie

"Beginning PHP and MySQL E-Commerce: From Novice to Professional, Second Edition"

Create a new presentation object file named admin_login.php in the presentation folder, and type the
following code:
// Class that deals with authenticating administrators
class AdminLogin
{
// Public variables available in smarty templates
public $mUsername;
public $mLoginMessage = '';
public $mLinkToAdmin;
public $mLinkToIndex;
// Class constructor
public function __construct()
{
// Verify if the correct username and password have been supplied
if (isset ($_POST['submit']))
{
if ($_POST['username'] == ADMIN_USERNAME
&& $_POST['password'] == ADMIN_PASSWORD)
{
$_SESSION['admin_logged'] = true;
header('Location: ' . Link::ToAdmin());
exit();
}
else
CHAPTER 10 ?–  CATALOG ADMINISTRATION: DEPARTMENTS AND CATEGORIES 280
$this->mLoginMessage = 'Login failed. Please try again:';
}
$this->mLinkToAdmin = Link::ToAdmin();
$this->mLinkToIndex = Link::ToIndex();
}
}
?>
9. Create presentation/templates/admin_menu.tpl, and add the following code:
{* admin_menu.tpl *}
{load_presentation_object filename="admin_menu" assign="obj"}

TShirtShop Admin


|
CATALOG ADMIN |
STOREFRONT |
LOGOUT |


10. Now, create a new file named admin_menu.php in the presentation folder, and add the following code:
class AdminMenu
{
public $mLinkToStoreAdmin;
public $mLinkToStoreFront;
public $mLinkToLogout;
public function __construct()
{
$this->mLinkToStoreAdmin = Link::ToAdmin();
$this->mLinkToStoreFront = Link::ToIndex();
$this->mLinkToLogout = Link::ToLogout();
}
}
?>
11.


Pages:
376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400
poker online słownik teksty piosenek poker no limit imprezy integracyjne dla firm