Prev | Current Page 392 | Next

Emilian Balanescu and Cristian Darie

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

In the __construct function, we test whether the supplied
username and password match the values stored in config.php as ADMIN_USERNAME and ADMIN_PASSWORD;
if they match, we set the value of admin_logged to true and redirect to admin.php:
CHAPTER 10 ?–  CATALOG ADMINISTRATION: DEPARTMENTS AND CATEGORIES 284
// 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
$this->mLoginMessage = 'Login failed. Please try again:';
}
The logout link in admin_menu.tpl simply unsets the admin_logged session variable in store_admin.php
and redirects the administrator to admin.php. This way, on the next attempt to access the administration page,
the administrator will be redirected to the login page.
// If logging out ...
if (isset ($_GET['Page']) && ($_GET['Page'] == 'Logout'))
{
unset($_SESSION['admin_logged']);
header('Location: ' . Link::ToAdmin());
exit();
}
Administering Departments
The department administration section allows the user to add, remove, and change department
information. To implement this functionality, you??™ll need to write the necessary code for
the presentation, business, and data layers.
One fundamental truth regarding n-tiered applications (which applies to this particular
case) is that the business and data tiers are ultimately created to support the presentation tier.


Pages:
380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404