Advertisement
Guest User

Untitled

a guest
Feb 28th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.78 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  7. <title>Register Pesbuk</title>
  8.  
  9. <link rel="stylesheet" href="css/bootstrap.min.css" />
  10. </head>
  11. <body class="bg-light">
  12.  
  13. <div class="container mt-5">
  14. <div class="row">
  15. <div class="col-md-6">
  16.  
  17. <p>&larr; <a href="index.php">Home</a>
  18.  
  19. <h4>Bergabunglah bersama ribuan orang lainnya...</h4>
  20. <p>Sudah punya akun? <a href="login.php">Login di sini</a></p>
  21.  
  22. <form action="" method="POST">
  23.  
  24. <div class="form-group">
  25. <label for="name">Nama Lengkap</label>
  26. <input class="form-control" type="text" name="name" placeholder="Nama kamu" />
  27. </div>
  28.  
  29. <div class="form-group">
  30. <label for="username">Username</label>
  31. <input class="form-control" type="text" name="username" placeholder="Username" />
  32. </div>
  33.  
  34. <div class="form-group">
  35. <label for="email">Email</label>
  36. <input class="form-control" type="email" name="email" placeholder="Alamat Email" />
  37. </div>
  38.  
  39. <div class="form-group">
  40. <label for="password">Password</label>
  41. <input class="form-control" type="password" name="password" placeholder="Password" />
  42. </div>
  43.  
  44. <input type="submit" class="btn btn-success btn-block" name="register" value="Daftar" />
  45.  
  46. </form>
  47.  
  48. </div>
  49.  
  50. <div class="col-md-6">
  51. <img class="img img-responsive" src="img/connect.png" />
  52. </div>
  53.  
  54. </div>
  55. </div>
  56.  
  57.  
  58. <?php
  59. require_once("config.php");
  60. if (isset($_POST['register'])) {
  61. $name = filter_input(INPUT_POST, 'name', FILTER_SANITIZE_STRING);
  62. $username = filter_input(INPUT_POST,'username',FILTER_SANITIZE_STRING);
  63. $email = filter_input(INPUT_POST,'email', FILTER_SANITIZE_EMAIL);
  64. $password = Password_hash($_POST["password"],PASSWORD_DEFAULT);
  65.  
  66. //insert data ke database
  67. $sql = "INSERT INTO user (name, username, email, password) VALUES(:name,:username, :email, :password)";
  68. $stmt = $db->prepare($sql);
  69.  
  70.  
  71. //bind parameter ke quey
  72. $params = array(
  73. ":name" => $name,
  74. ":username" => $username,
  75. ":password" => $password,
  76. ":email" => $email
  77. );
  78. //untuk menyimpan ke database
  79. $saved = $stmt -> execute($params);
  80.  
  81. //ketika query sudah berhasil disimpan maka akan beralih ke halaman login
  82. if($saved) header("location : login.php");
  83.  
  84. }
  85. ?>
  86.  
  87. </body>
  88. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement