Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include('check.php');
- $subtitle = "Pengaturan";
- if (isset($_POST['settings'])) {
- $pass = $_POST['password'];
- $newpass = $_POST['newpassword'];
- $newpass2 = $_POST['newpassword2'];
- $mdnewpass = md5($newpass);
- $qcp = mysqli_query($db,"SELECT * FROM users WHERE username = '$username'");
- $rowp = mysqli_fetch_array($qcp,MYSQLI_ASSOC);
- if (!$pass || !$newpass || !$newpass2) {
- $error = "Masih ada data yang kosong.";
- } else if ($rowp['show_password'] <> $pass) {
- $error = "Password salah.";
- } else if ($newpass <> $newpass2) {
- $error = "Password konfirmasi salah.";
- } else if (strlen($newpass) < 5) {
- $error = "Password baru terlalu pendek. Minimal 5 karakter.";
- } else {
- $update = mysqli_query($db,"UPDATE users SET password = '$mdnewpass', show_password = '$newpass' WHERE username = '$username'");
- if ($update == TRUE) {
- $success = "Password berhasil diubah.";
- } else {
- $error = "Error database. (Update)";
- }
- }
- }
- include('header.php');
- ?>
- <!-- Start content -->
- <div class="content">
- <div class="container">
- <!-- Page-Title -->
- <div class="row">
- <div class="col-sm-12">
- <h4 class="pull-left page-title"><?php echo $subtitle; ?></h4>
- <ol class="breadcrumb pull-right">
- <li><a href="#"><?php echo $title; ?></a>
- </li>
- <li class="active"><?php echo $subtitle; ?></li>
- </ol>
- </div>
- </div>
- <div class="row">
- <div class="col-lg-12">
- <?php if (isset($error)) { ?>
- <div class="alert alert-danger">
- <b>Gagal : </b><?php echo $error; ?>
- </div>
- <? } else if (isset($success)) { ?>
- <div class="alert alert-success">
- <b>Berhasil : </b><?php echo $success; ?>
- </div>
- <? } ?>
- <div class="panel panel-color panel-primary">
- <div class="panel-heading">
- <h3 class="panel-title"><i class="md md-settings"></i> <?php echo $subtitle; ?></h3>
- </div>
- <div class="panel-body">
- <form class="form-horizontal" role="form" method="POST" action="settings.php">
- <div class="form-group">
- <label class="col-sm-2 control-label">Password Sekarang</label>
- <div class="col-sm-10">
- <input type="password" class="form-control" name="password" placeholder="Password lama">
- </div>
- </div>
- <div class="form-group">
- <label class="col-sm-2 control-label">Password Baru</label>
- <div class="col-sm-10">
- <input type="password" class="form-control" name="newpassword" placeholder="Password baru">
- </div>
- </div>
- <div class="form-group">
- <label class="col-sm-2 control-label">Konfirmasi Password Baru</label>
- <div class="col-sm-10">
- <input type="password" class="form-control" name="newpassword2" placeholder="Konfirmasi password baru">
- </div>
- </div>
- <div class="form-group m-b-0">
- <div class="col-sm-offset-2 col-sm-10">
- <button name="settings" type="submit" class="btn btn-info waves-effect waves-light"><i class="md md-settings"></i> Ubah Password</button>
- </div>
- </div>
- </form>
- </div>
- </div>
- </div>
- </div>
- <!-- end row -->
- </div>
- <!-- container -->
- </div>
- <!-- content -->
- <?php include('footer.php'); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement