Prev | Current Page 389 | Next

Emilian Balanescu and Cristian Darie

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

Open presentation/link.php file, and modify the Build() method of the Link class as highlighted in
the following code snippet. This adds support for secure (HTTPS) links:
public static function Build($link, $type = 'http')
{
$base = (($type == 'http' || USE_SSL == 'no') ? 'http://' : 'https://') .
getenv('SERVER_NAME');
// If HTTP_SERVER_PORT is defined and different than default
if (defined('HTTP_SERVER_PORT') && HTTP_SERVER_PORT != '80' &&
strpos($base, 'https') === false)
{
CHAPTER 10 ?–  CATALOG ADMINISTRATION: DEPARTMENTS AND CATEGORIES 281
// Append server port
$base .= ':' . HTTP_SERVER_PORT;
}
$link = $base . VIRTUAL_LOCATION . $link;
// Escape html
return htmlspecialchars($link, ENT_QUOTES);
}
12. Also in presentation/link.php, add the following methods at the end of the Link class:
// Create link to admin page
public static function ToAdmin($params = '')
{
$link = 'admin.php';
if ($params != '')
$link .= '?' . $params;
return self::Build($link, 'https');
}
// Create logout link
public static function ToLogout()
{
return self::ToAdmin('Page=Logout');
}
13. Add the following styles to the styles/tshirtshop.css file:
.login {
color: #333333;
display: block;
border: 1px solid #c6e1ec;
margin: 50px auto;
width: 325px;
}
.login form p {
padding: 0 10px;
}
label {
display: block;
}
CHAPTER 10 ?–  CATALOG ADMINISTRATION: DEPARTMENTS AND CATEGORIES 282
.


Pages:
377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401
Apartamenty Świnoujście noclegi hel Lokaty jednodniowe projekty domków letniskowych męskie skarpetki rowerowe