-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
63 lines (55 loc) · 2.98 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
include_once('age.php');
if(isset($_POST['dob'])){
$person = new Age($_POST['dob']);
$person->ageCalculation();
}
?>
<!-- Add header(link stylesheets, jquery, bootstrap) -->
<?php include_once('layout/header.php'); ?>
<ol class="breadcrumb">
<li><a href="https://sbsharma.com">Home</a></li>
<li><a href="https://sbsharma.com/php">PHP</a></li>
<li class="active">Age calculator</li>
</ol>
<div class="container">
<div class="page-header">
<h1>Age calculator</h1>
</div>
<div class="row">
<div class="col-md-4 col-md-offset-4">
<div class="panel panel-default theme-color mt-1">
<!-- Default panel contents -->
<div class="panel-heading theme-color text-center"><span class="glyphicon glyphicon-calendar"></span> Age Calculator</div>
<div class="panel-body">
<form class="form-inline text-center" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
<div class="form-group">
<input type="text" name="dob" class="form-control datepicker" placeholder="Select Date of Birth"
<?php if(isset($_POST['dob'])) { ?>value="<?= $person->dateOfBirth->format('d-m-Y'); ?>"<?php } ?>
/>
</div>
<div class="form-group">
<button type="submit" class="form-control btn btn-dark"><span class="glyphicon glyphicon-check"></span> Calculate</button>
</div>
</form>
<div class="mt-1">
<?php if(isset($_POST['dob'])) { ?>
<div class="alert alert-warning alert-dismissible text-center" role="alert">
Today is <?= $person->today->format('d-m-Y'); ?>
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="alert alert-success text-center" role="alert">
The age is <?= $person->age->y ?> years <?= $person->age->m ?> months <?= $person->age->d ?> days old
</div>
<?php } ?>
</div>
</div>
<div class="panel-footer theme-color text-center">Powered by <a class="link-color" href="https://sbsharma.com" target="_blank">www.sbsharma.com</a></div>
</div>
</div>
</div>
</div>
<!-- Add footer(js scripts) -->
<?php include_once('layout/footer.php'); ?>