PHP Classes

File: fday_test.php

Recommend this page to a friend!
  Classes of Pierre FAUQUE   PHP Holidays for Family Members Class   fday_test.php   Download  
File: fday_test.php
Role: Example script
Content type: text/plain
Description: Example of use
Class: PHP Holidays for Family Members Class
Get the holiday dates of the Mother, Father, etc.
Author: By
Last change:
Date: 1 year ago
Size: 3,170 bytes
 

Contents

Class file image Download
<?php
require("class.fday.php");
if(isset(
$_POST["submit"])) { $year = $_POST["year"]; } else { $year = ""; }
$fd = new fday($year);
?><!DOCTYPE html>
<html>

<head>

  <meta name="author" content="Pierre FAUQUE, pierre@fauque.net">
  <title>Test: class.fday.php</title>

  <style type="text/css">
    body { margin-left:2em; margin-top:2em; }
    .c1 { padding-left:6px; padding-right:6px; border:1px solid grey; }
    .c2 { padding-left:6px; padding-right:6px; border:1px solid grey; border-left:0; }
    .c3 { padding-left:6px; padding-right:6px; border:1px solid grey; border-top:0; }
    .c4 { padding-left:6px; padding-right:6px; border:1px solid grey; border-top:0; border-left:0; }
  </style>

  <script language="javascript" type="text/javascript">
  function verif() {
      var n;
      var authorizedchar = "0123456789";
      var year = document.fday.year.value;
      if(year.length != 0 && year.length != 4) {
          alert('The year must be written with four digits');
          document.fday.year.value = "";
          document.fday.year.focus();
          return false;
      }
      for(n=0; n<4; n++) {
          if(authorizedchar.indexOf(year.substring(n,n+1)) < 0) {
              alert('The year must only be written with digits');
              document.fday.year.value = "";
             document.fday.year.focus();
              return false;
          }
      }
      return true;
  }
  </script>

</head>

<body>



<form name="fday" method="post" action="<?php echo $_SERVER["PHP_SELF"]; ?>" onsubmit="return verif()">
Year : <input type="text" name="year" size="4" placeholder="<?php echo date("Y"); ?>">
<input type="submit" name="submit" value="OK">

<?php if(isset($_POST["submit"])) { ?>

<p><?php if(!$year) { echo "<h1>".date("Y")."</h1>"; } else { echo "<h1>$year</h1>"; } ?></p>

<table cellspacing="0">
  <tr><td class="c1">Mother day</td><td class="c2"><?php echo $fd->md; ?></td></tr>
  <tr><td class="c3">Father day</td><td class="c4"><?php echo $fd->fd; ?></td></tr>
  <tr><td class="c3">Grandmother day</td><td class="c4"><?php echo $fd->gmd; ?></td></tr>
  <tr><td class="c3">Grandfather day</td><td class="c4"><?php echo $fd->gfd; ?></td></tr>
</table>

<br/>

<table cellspacing="0">
  <tr>
    <td class="c1">Easter</td>
    <td class="c2"><?php echo $fd->easter; ?></td>
  </tr><tr>
    <td class="c3">Whitsun</td>
    <td class="c4"><?php echo $fd->wsun; ?></td>
  </tr><tr>
    <td class="c3">Today</td>
    <td class="c4"><b><?php echo $fd->today; ?></b></td>
  </tr><tr>
    <td class="c3">Is today the mother day ?</td>
    <td class="c4"><?php if($fd->ismd()) { echo "Yes"; } else { echo "No"; } ?></td>
  </tr><tr>
    <td class="c3">Is today the father day ?</td>
    <td class="c4"><?php if($fd->isfd()) { echo "Yes"; } else { echo "No"; } ?></td>
  </tr><tr>
    <td class="c3">Is today the grandmother day ?</td>
    <td class="c4"><?php if($fd->isgmd()) { echo "Yes"; } else { echo "No"; } ?></td>
  </tr><tr>
    <td class="c3">Is today the grandfather day ?</td>
    <td class="c4"><?php if($fd->isgfd()) { echo "Yes"; } else { echo "No"; } ?></td>
  </tr>
</table>

<?php } ?>
</form>

</body>

</html>