File: core/test.php

Recommend this page to a friend!
  Classes of No name  >  RT PHP Mykad Reader  >  core/test.php  >  Download  
File: core/test.php
Role: Example script
Content type: text/plain
Description: Example script
Class: RT PHP Mykad Reader
Validate and get a Malasyan MyKad identity number
Author: By
Last change:
Date: 3 years ago
Size: 2,711 bytes
 

Contents

Class file image Download
<?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>


For more information send a message to info at phpclasses dot org.