Advertisement
Guest User

Untitled

a guest
Nov 20th, 2018
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.27 KB | None | 0 0
  1. ================= No. 3 =================
  2. <!DOCTYPE html>
  3. <html lang="en">
  4. <head>
  5. <title>Sistem Otentikasi</title>
  6. <link rel="stylesheet" href="assets/style.css">
  7. </head>
  8. <body>
  9. <header>
  10. <h1>Training PHP - OOP</h1>
  11. <nav>
  12. <a href="login.php">Sign In</a>
  13. <a href="daftar.php">Register</a>
  14. <a href="profile.php">Profile</a>
  15. </nav>
  16. </header>
  17.  
  18.  
  19.  
  20. ================= No. 4 =================
  21.  
  22. <footer>Training PHP - OOP 2017</footer>
  23. </body>
  24. </html>
  25.  
  26.  
  27.  
  28. ================= No. 5 =================
  29. * {
  30. margin:0px;
  31. padding:0px;
  32. font-family:sans-serif;
  33. }
  34. body {
  35. width:80%;
  36. margin:20px auto;
  37. }
  38. header {
  39. border-bottom: 2px solid grey;
  40. padding-bottom: 10px;
  41. margin-bottom: 50px;
  42. }
  43. footer {
  44. border-top: 2px solid grey;
  45. padding-top: 10px;
  46. margin-top: 50px;
  47. }
  48.  
  49.  
  50.  
  51. ================= No. 6 =================
  52. <?php
  53. class Database{
  54. private static $INSTANCE = null;
  55. private $con,
  56. $HOST = 'localhost',
  57. $USER = 'root',
  58. $PASS = '',
  59. $DBNAME = 'dbPegawai';
  60.  
  61. public function __construct(){
  62. $this->con = new mysqli($this->HOST, $this->USER, $this->PASS, $this->DBNAME);
  63. if (mysqli_connect_error()){
  64. die ('Anda Tidak Terhubung Ke Database');
  65. }
  66. }
  67. /*singleton pattern,
  68. menguji koneksi agar tidak double*/
  69. public static function getInstance(){
  70. if ( isset(self::$INSTANCE() ){
  71. self::$INSTANCE = new Database();
  72. }
  73. return self::$INSTANCE
  74. }
  75. }
  76. //database::getInstance();
  77. //$db = Database::getInstance();
  78. //var_dump($db);
  79. ?>
  80.  
  81.  
  82.  
  83. ================= No. 7 =================
  84. <?php
  85. session_start();
  86.  
  87. //load class
  88. spl_autoload_register(function($class){
  89. require_once 'pages/' .$class. '.php';
  90. });
  91. ?>
  92.  
  93.  
  94.  
  95. ================= No. 8 =================
  96. <?php
  97. require_once"config/init.php";
  98. $db = new Database();
  99. echo "Kalo Baca Tulisan Ini Berarti Script Yang Dibikin Udah Bener, Good Job ^_^";
  100. ?>
  101.  
  102.  
  103.  
  104. ================= No. 9 =================
  105. <?php
  106. require_once 'config/init.php';
  107. require_once 'templates/header.html';
  108. ?>
  109. <form action = "register.php" method = "post">
  110. <pre>
  111. <label>Username :</label> <input type="text" name="username">
  112. <label>Password :</label> <input type="password" name="password">
  113. <label>Nama :</label> <input type="text" name="txtNama">
  114.  
  115. <input type = "submit" value = " Register ">
  116. </pre>
  117. </form>
  118.  
  119. <?php
  120. require_once 'templates/footer.html';
  121. ?>
  122.  
  123.  
  124.  
  125. ================= No. 10 =================
  126. <?php
  127. class Input{
  128. public static function get($name){
  129. if ( isset($_POST[$name]) ){
  130. return $_POST[$name];
  131. }
  132. else if ( isset($_GET[$name]) ){
  133. return $_GET[$name];
  134. }
  135. }
  136. return false;
  137. }
  138. ?>
  139.  
  140.  
  141.  
  142. ================= No. 11 =================
  143. <?php
  144. require_once 'config/init.php';
  145. //validasi
  146. if(Input::get('submit')){
  147. $pegawai->register_pegawai(array(
  148. //key => value
  149. 'kode' => Input::get('username'),
  150. 'password' => password_hash(Input::get('password'), PASSWORD_DEFAULT),
  151. 'nama' => Input::get('txtNama')
  152. ));
  153. }
  154. require_once 'templates/header.php';
  155. ?>
  156. <h2>Daftar Sekarang</h2>
  157. <form action = "register.php" method = "post">
  158.  
  159. <label>Username :</label> <input type="text" name="username">
  160. <label>Password :</label> <input type="password" name="password">
  161. <label>Nama :</label> <input type="text" name="txtNama">
  162.  
  163. <input type = "submit" value = " Register ">
  164.  
  165. </form>
  166.  
  167. <?php
  168. require_once 'templates/footer.html';
  169. ?>
  170.  
  171.  
  172.  
  173. ================= No. 12 =================
  174. <?php
  175. session_start();
  176.  
  177. //load class
  178. spl_autoload_register(function($class){
  179. require_once 'pages/' .$class. '.php';
  180. });
  181. $pegawai = new Pegawai();
  182. ?>
  183.  
  184.  
  185.  
  186. ================= No. 13 =================
  187. <?php
  188. class Pegawai{
  189. private $_db;
  190. public function __construct(){
  191. this->_db = Database::getInstance();
  192. }
  193. public function register_pegawai($fields = array()){
  194. if($this->_db->insert('tpegawai1', $fields)){
  195. return true;
  196. }
  197. else
  198. return false;
  199. }
  200. }
  201. ?>
  202.  
  203.  
  204.  
  205. ================= No. 14 =================
  206.  
  207. ================= No. 15 =================
  208.  
  209. ================= No. 16 =================
  210.  
  211. ================= No. 17 =================
  212.  
  213. ================= No. 18 =================
  214.  
  215. ================= No. 19 =================
  216.  
  217. ================= No. 20 =================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement