Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require 'koneksi.php';
- $username_err=$password_err=$sukses='';
- $username_ket=$password_ket=false;
- if(isset($_POST['submit'])){
- $instansi=$_POST['instansi'];
- $alamat=$_POST['alamat'];
- $username=$_POST['username'];
- $telepon=$_POST['telepon'];
- $password=password_hash($_POST['password'],PASSWORD_DEFAULT);
- //echo ($_POST['password']); 'hanya untuk cek'
- //echo password_hash($_POST['password'],PASSWORD_DEFAULT); 'hanya untuk cek'
- if (cek_username($username)==1){
- $username_err='username tidak tersedia';
- } else {
- $username_ket=true;
- }
- if ($_POST['password']!=$_POST['kpassword']){
- $password_err='password tidak cocok';
- } else {
- $password_ket=true;
- }
- if($username_ket=true && $password_ket=true) {
- $insert=$db_master->prepare("insert into master_instansi(instansi, alamat, user_register, telepon, password) VALUES (:instansi,:alamat,:username,:telepon,:password)");
- $insert->bindParam(':instansi',$instansi,PDO::PARAM_STR);
- $insert->bindParam(':alamat',$alamat,PDO::PARAM_STR);
- $insert->bindParam(':user_register',$username,PDO::PARAM_STR);
- $insert->bindParam(':telepon',$telepon,PDO::PARAM_STR);
- $insert->bindParam(':password',$password,PDO::PARAM_STR);
- /*echo($instansi); cek isi
- echo($alamat);
- echo($user);
- echo($telepon);
- echo($password);*/
- $insert->execute();
- //$result = $insert->fetchAll(PDO::fetch_assoc);
- //$insert->execute(array(':instansi'=>$instansi,':alamat'=>$alamat,':user_register'=>$username, ':telepon'=>$telepon, ':password'=>$password));
- $sukses='Registrasi Berhasil.< a href="login.php"> Login disini</a>';
- }
- }
- function cek_username($username){
- global $db_master;
- $cek=$db_master->prepare("select user_register from master_instansi where user_register=:username");
- $cek->bindParam(':username',$username, PDO::PARAM_STR);
- return $cek->rowCount();
- }
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <title>Register User</title>
- <link rel="stylesheet" href="style.css">
- </head>
- <body>
- <div class="container center">
- <div class="header">
- <h2>Registrasi System</h2>
- </div>
- <div class="box">
- <form action="" method="POST">
- <center><?php echo $sukses; ?></center>
- <label>Instansi</label>
- <input type="text" class="control" name="instansi" placeholder="Instansi Terkait" required>
- <p class="error"></p>
- <label>Alamat</label>
- <input type="text" class="control" name="alamat" placeholder="Alamat Instansi" required>
- <p class="error"></p>
- <label>Username</label>
- <input type="text" class="control" name="username" placeholder="Username Login" required>
- <p class="error"><?php echo $username_err; ?></p>
- <label>Telepon</label>
- <input type="text" class="control" name="telepon" placeholder="Telepon User" required>
- <p class="error"></p>
- <label>Password</label>
- <input type="password" class="control" name="password" placeholder="Password" required>
- <p class="error"></p>
- <label>Konfirmasi Password</label>
- <input type="password" class="control" name="kpassword" placeholder="Password" required>
- <p class="error"><?php echo $password_err; ?></p>
- <input type="submit" name="submit" value="Register">
- <div style="float: right; margin-top: 5px">
- <a style="text-decoration: none" href="login.php">Login</a>
- </div>
- </form>
- </div>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement