<?php
/**
* @link https://github.com/rogertiongdev/RTMykad RTMykad GitHub project
* @license https://rogertiongdev.github.io/MIT-License/
*/
require_once dirname(__FILE__) . '/RTMykad.php';
if (isset($_POST['nric'])) {
$RTMykad = new RTMykad();
$RTMykad->setMyKad($_POST['nric']);
if ($RTMykad->isValid()) {
$result = $RTMykad->getData();
}
else {
$alert = 'NRIC No. given is in invalid format.';
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>RTMykad</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<h2>RTMykad Test</h2>
<form action="" method="post">
<div class="form-group">
<label>NRIC No:</label>
<input type="text" class="form-control" name="nric" required>
<?php
if (isset($alert) && !empty($alert)) {
print sprintf('<span style="color:#ff0000;">%s</span>', $alert);
}
?>
</div>
<button type="submit" class="btn btn-default">GET INFO</button>
</form>
<?php
if (isset($result) && !empty($result)) {
?>
<br><br>
<h2>Result</h2>
<div class="table-responsive">
<table class="table table-bordered">
<tr>
<td style="width:20%">NRIC No:</td>
<td style="width:80%"><?php print $result['display']; ?></td>
</tr>
<tr>
<td>Birth Date:</td>
<td><?php print $result['bdate']; ?></td>
</tr>
<tr>
<td>Gender:</td>
<td><?php print $result['gender']; ?></td>
</tr>
<tr>
<td>State:</td>
<td><?php print $result['state']; ?></td>
</tr>
</table>
</div>
<?php
}
?>
</div>
</body>
</html>
|