- 18, May 2024
- #1
Может кто-нибудь подсказать мне, почему это не работает. Это код, сообщающий об истечении срока действия контракта.
======================================================================
следующий код:
---------------------------------------
<?php
error_reporting(E_ALL);
// show all errors - server configured at 6135, increases to 6143 (PHP version 5.2.11) --
// comment this line out when LIVE
ini_set('display_errors','On');
// turn on error display -- comment this line out when LIVE
$contract_expiration = '2020-12-31'; // set expiration date in YYYY-MM-DD format
$days_remaining = round( (( strtotime($contract_expiration) - strtotime(date('Y-m-d')) ) / (60*60*24)) );
// computes days remaining -- (60s*60m*24h) represents 1 day
if ($days_remaining < 31) {
$contract_expiration_formatted = date('n/j/y',strtotime($contract_expiration));
// formats expiration date as M/D/YY
if ($days_remaining == 7) $GLOBALS['contract_status'] = 'expires in a week!';
// alert message for contracts expiring today
elseif ($days_remaining == 1) $GLOBALS['contract_status'] = 'expires tomorrow!';
// alert message for contracts expiring tomorrow
else $GLOBALS['contract_status'] = 'expires in '.$days_remaining.' days - on '.$contract_expiration_formatted;
// alert message for contracts expiring in 2-30 days
}
else $GLOBALS['contract_status'] = 'is current'; // contract period is beyond 30 days
// ============================= blows up here ==================================
if (date('Y-m-d') > $contract_expiration) {
if today's date is greater than your expiration date
header("location:expired-page.html");
echo "We're sorry but your contract has expired. Contact us immediately at [EMAIL][email protected][/EMAIL] ";
// a status alert message or you can populate with a web document
exit; // kills the script and prevents the parser from rendering your web application below
}
else { ?>
<HTML>
<HEAD>
</head>
<body>
<iframe src="nav.html" width="100%" height="30"
style="height:1.8em scrolling="no"
marginwidth="0" marginheight="0" border: none;>
</iframe>
<br>
<iframe src="info.html" width="100%" height="60"
style="height:1.8em scrolling="no"
marginwidth="0" marginheight="0" border: none;>
</iframe>
<?=$GLOBALS['expiration_status'];?>
</html>
<?php } ?>
==========================================
result follows:
---------------------
$contract_expiration) { if today's date is greater than your expiration date header
("location:expired-page.html"); echo "We're sorry but your contract has expired.
// a status alert message or you can
populate with a web document exit; // kills the script and prevents the parser from
rendering your web application below } else { ?>
Код (php):