Advertisement
justhrun

gantipass.pehape

May 29th, 2015
318
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.10 KB | None | 0 0
  1. <?php
  2. session_start();
  3. error_reporting(1);
  4. include 'inc/koneksi.php';
  5. if(empty($_SESSION['login'])) {
  6.     header("Location:index.php");
  7.     exit;
  8. }
  9.  ?>
  10. <!doctype html>
  11. <html>
  12. <link rel="shortcut icon" type="image/x-icon" href="images/lamp-b.ico" />
  13. <head>
  14. <meta charset="utf-8">
  15. <title>Change Password</title>
  16. <meta name="viewport" content="width=device-width, initial-scale=1">
  17. <link href="jquery-mobile/jquery.mobile-1.0.min.css" rel="stylesheet" type="text/css">
  18. <script src="jquery-mobile/jquery-1.6.4.min.js" type="text/javascript"></script>
  19. <script src="jquery-mobile/jquery.mobile-1.0.min.js" type="text/javascript"></script>
  20. </head>
  21. <body>
  22. <div data-role="page" id="rubah password" data-theme="e">
  23.     <div data-role="header" data-position="fixed" data-theme="a">
  24.         <h3>Change Password</h3>
  25.     </div>
  26.     <div data-role="content">
  27.         <form name="submit" action="change-password.php" method="POST">
  28.             <label for="username">Username</label>
  29.             <input type="text" name="username" id="username" value="" data-mini="true" size="15" maxlength="32" required />
  30.             <label for="password">Old Password</label>
  31.             <input type="password" name="password" id="password" value="" data-mini="true" size="15" maxlength="15" required />
  32.             <label for="newpassword">New Password</label>
  33.             <input type="password" name="newpassword" id="newpassword" value="" data-mini="true" size="15" maxlength="15" required />
  34.             <label for="konfirpassword">Confirm New Password</label>
  35.             <input type="password" name="konfirpassword" id="konfirpassword" value="" data-mini="true" size="15" maxlength="15" required />
  36.             <div data-role="fieldcontain" align="left">
  37.             <input type="submit" value="submit" data-theme="c" data-role="button" name="submit" data-icon="check" data-theme="b" data-inline="true">
  38.             </div>
  39.         </form>
  40.     </div>
  41. </div>
  42. </body>
  43. </html>
  44. <?php
  45. if(count($_POST)) {
  46.     $username = $_POST['username'];  
  47.     $password = $_POST['password'];  
  48.     $newpassword = $_POST['newpassword'];
  49.     $konfirpassword = $_POST['konfirpassword'];
  50.     $result = mysql_query("SELECT * FROM tbl_user WHERE username='$username' and password='$password'");
  51.     if(!$result)  {  
  52. ?>
  53.         <script language="javascript">
  54.             alert("Username / Old PAssword Anda Salah.");
  55.             document.location="change-password.php";
  56.         </script>
  57. <?php
  58.     //echo "The username you entered does not exist";  
  59.     }  else {
  60.         // if($password!= mysql_result($result, 0))  {  
  61.         // baris ini gk perlu, karena sampe di sini berarti $result ada isinya, krn password-nya benar
  62.         if ($newpassword!=$konfirpassword) {
  63. ?>
  64.             <script language="javascript">
  65.                 alert("Password Anda Tidak Sama.");
  66.                 document.location="index.php";
  67.             </script>
  68. <?php  
  69.         } else {
  70.             mysql_query("UPDATE user SET password='$newpassword' where username='$username'");
  71.             if(mysql_affected_rows()) {
  72. ?>
  73.                 <script language="javascript">
  74.                     alert("Password Berhasil diganti.");
  75.                     document.location="index.php";
  76.                 </script>
  77. <?php  
  78.             } else {
  79. ?>
  80.                 <script language="javascript">
  81.                     alert("Gagal Ganti Password.");
  82.                     document.location="change-password.php";
  83.                 </script>
  84. <?
  85.             }
  86.         }
  87.     }
  88. }
  89. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement