Advertisement
Guest User

Untitled

a guest
Dec 6th, 2016
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.45 KB | None | 0 0
  1. <?php
  2.  
  3. include('check.php');
  4. $subtitle = "Pengaturan";
  5.  
  6. if (isset($_POST['settings'])) {
  7. $pass = $_POST['password'];
  8. $newpass = $_POST['newpassword'];
  9. $newpass2 = $_POST['newpassword2'];
  10. $mdnewpass = md5($newpass);
  11.  
  12. $qcp = mysqli_query($db,"SELECT * FROM users WHERE username = '$username'");
  13. $rowp = mysqli_fetch_array($qcp,MYSQLI_ASSOC);
  14.  
  15. if (!$pass || !$newpass || !$newpass2) {
  16. $error = "Masih ada data yang kosong.";
  17. } else if ($rowp['show_password'] <> $pass) {
  18. $error = "Password salah.";
  19. } else if ($newpass <> $newpass2) {
  20. $error = "Password konfirmasi salah.";
  21. } else if (strlen($newpass) < 5) {
  22. $error = "Password baru terlalu pendek. Minimal 5 karakter.";
  23. } else {
  24. $update = mysqli_query($db,"UPDATE users SET password = '$mdnewpass', show_password = '$newpass' WHERE username = '$username'");
  25. if ($update == TRUE) {
  26. $success = "Password berhasil diubah.";
  27. } else {
  28. $error = "Error database. (Update)";
  29. }
  30. }
  31. }
  32.  
  33. include('header.php');
  34. ?>
  35. <!-- Start content -->
  36. <div class="content">
  37. <div class="container">
  38. <!-- Page-Title -->
  39. <div class="row">
  40. <div class="col-sm-12">
  41. <h4 class="pull-left page-title"><?php echo $subtitle; ?></h4>
  42. <ol class="breadcrumb pull-right">
  43. <li><a href="#"><?php echo $title; ?></a>
  44. </li>
  45. <li class="active"><?php echo $subtitle; ?></li>
  46. </ol>
  47. </div>
  48. </div>
  49. <div class="row">
  50. <div class="col-lg-12">
  51. <?php if (isset($error)) { ?>
  52. <div class="alert alert-danger">
  53. <b>Gagal : </b><?php echo $error; ?>
  54. </div>
  55. <? } else if (isset($success)) { ?>
  56. <div class="alert alert-success">
  57. <b>Berhasil : </b><?php echo $success; ?>
  58. </div>
  59. <? } ?>
  60. <div class="panel panel-color panel-primary">
  61. <div class="panel-heading">
  62. <h3 class="panel-title"><i class="md md-settings"></i> <?php echo $subtitle; ?></h3>
  63. </div>
  64. <div class="panel-body">
  65. <form class="form-horizontal" role="form" method="POST" action="settings.php">
  66. <div class="form-group">
  67. <label class="col-sm-2 control-label">Password Sekarang</label>
  68. <div class="col-sm-10">
  69. <input type="password" class="form-control" name="password" placeholder="Password lama">
  70. </div>
  71. </div>
  72. <div class="form-group">
  73. <label class="col-sm-2 control-label">Password Baru</label>
  74. <div class="col-sm-10">
  75. <input type="password" class="form-control" name="newpassword" placeholder="Password baru">
  76. </div>
  77. </div>
  78. <div class="form-group">
  79. <label class="col-sm-2 control-label">Konfirmasi Password Baru</label>
  80. <div class="col-sm-10">
  81. <input type="password" class="form-control" name="newpassword2" placeholder="Konfirmasi password baru">
  82. </div>
  83. </div>
  84. <div class="form-group m-b-0">
  85. <div class="col-sm-offset-2 col-sm-10">
  86. <button name="settings" type="submit" class="btn btn-info waves-effect waves-light"><i class="md md-settings"></i> Ubah Password</button>
  87. </div>
  88. </div>
  89. </form>
  90. </div>
  91. </div>
  92. </div>
  93.  
  94. </div>
  95. <!-- end row -->
  96. </div>
  97. <!-- container -->
  98. </div>
  99. <!-- content -->
  100. <?php include('footer.php'); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement