Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ================= No. 3 =================
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <title>Sistem Otentikasi</title>
- <link rel="stylesheet" href="assets/style.css">
- </head>
- <body>
- <header>
- <h1>Training PHP - OOP</h1>
- <nav>
- <a href="login.php">Sign In</a>
- <a href="daftar.php">Register</a>
- <a href="profile.php">Profile</a>
- </nav>
- </header>
- ================= No. 4 =================
- <footer>Training PHP - OOP 2017</footer>
- </body>
- </html>
- ================= No. 5 =================
- * {
- margin:0px;
- padding:0px;
- font-family:sans-serif;
- }
- body {
- width:80%;
- margin:20px auto;
- }
- header {
- border-bottom: 2px solid grey;
- padding-bottom: 10px;
- margin-bottom: 50px;
- }
- footer {
- border-top: 2px solid grey;
- padding-top: 10px;
- margin-top: 50px;
- }
- ================= No. 6 =================
- <?php
- class Database{
- private static $INSTANCE = null;
- private $con,
- $HOST = 'localhost',
- $USER = 'root',
- $PASS = '',
- $DBNAME = 'dbPegawai';
- public function __construct(){
- $this->con = new mysqli($this->HOST, $this->USER, $this->PASS, $this->DBNAME);
- if (mysqli_connect_error()){
- die ('Anda Tidak Terhubung Ke Database');
- }
- }
- /*singleton pattern,
- menguji koneksi agar tidak double*/
- public static function getInstance(){
- if ( isset(self::$INSTANCE() ){
- self::$INSTANCE = new Database();
- }
- return self::$INSTANCE
- }
- }
- //database::getInstance();
- //$db = Database::getInstance();
- //var_dump($db);
- ?>
- ================= No. 7 =================
- <?php
- session_start();
- //load class
- spl_autoload_register(function($class){
- require_once 'pages/' .$class. '.php';
- });
- ?>
- ================= No. 8 =================
- <?php
- require_once"config/init.php";
- $db = new Database();
- echo "Kalo Baca Tulisan Ini Berarti Script Yang Dibikin Udah Bener, Good Job ^_^";
- ?>
- ================= No. 9 =================
- <?php
- require_once 'config/init.php';
- require_once 'templates/header.html';
- ?>
- <form action = "register.php" method = "post">
- <pre>
- <label>Username :</label> <input type="text" name="username">
- <label>Password :</label> <input type="password" name="password">
- <label>Nama :</label> <input type="text" name="txtNama">
- <input type = "submit" value = " Register ">
- </pre>
- </form>
- <?php
- require_once 'templates/footer.html';
- ?>
- ================= No. 10 =================
- <?php
- class Input{
- public static function get($name){
- if ( isset($_POST[$name]) ){
- return $_POST[$name];
- }
- else if ( isset($_GET[$name]) ){
- return $_GET[$name];
- }
- }
- return false;
- }
- ?>
- ================= No. 11 =================
- <?php
- require_once 'config/init.php';
- //validasi
- if(Input::get('submit')){
- $pegawai->register_pegawai(array(
- //key => value
- 'kode' => Input::get('username'),
- 'password' => password_hash(Input::get('password'), PASSWORD_DEFAULT),
- 'nama' => Input::get('txtNama')
- ));
- }
- require_once 'templates/header.php';
- ?>
- <h2>Daftar Sekarang</h2>
- <form action = "register.php" method = "post">
- <label>Username :</label> <input type="text" name="username">
- <label>Password :</label> <input type="password" name="password">
- <label>Nama :</label> <input type="text" name="txtNama">
- <input type = "submit" value = " Register ">
- </form>
- <?php
- require_once 'templates/footer.html';
- ?>
- ================= No. 12 =================
- <?php
- session_start();
- //load class
- spl_autoload_register(function($class){
- require_once 'pages/' .$class. '.php';
- });
- $pegawai = new Pegawai();
- ?>
- ================= No. 13 =================
- <?php
- class Pegawai{
- private $_db;
- public function __construct(){
- this->_db = Database::getInstance();
- }
- public function register_pegawai($fields = array()){
- if($this->_db->insert('tpegawai1', $fields)){
- return true;
- }
- else
- return false;
- }
- }
- ?>
- ================= No. 14 =================
- ================= No. 15 =================
- ================= No. 16 =================
- ================= No. 17 =================
- ================= No. 18 =================
- ================= No. 19 =================
- ================= No. 20 =================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement