Advertisement
Guest User

change-password.php

a guest
May 27th, 2015
1,794
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.04 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. }
  8.  
  9. ?>
  10.  
  11. <!doctype html>
  12. <html>
  13. <link rel="shortcut icon" type="image/x-icon" href="images/lamp-b.ico" />
  14. <head>
  15. <meta charset="utf-8">
  16. <title>Change Password</title>
  17. <meta name="viewport" content="width=device-width, initial-scale=1">
  18. <link href="jquery-mobile/jquery.mobile-1.0.min.css" rel="stylesheet" type="text/css">
  19. <script src="jquery-mobile/jquery-1.6.4.min.js" type="text/javascript"></script>
  20. <script src="jquery-mobile/jquery.mobile-1.0.min.js" type="text/javascript"></script>
  21. </head>
  22. <body>
  23.  
  24. <div data-role="page" id="rubah password" data-theme="e">
  25.  <div data-role="header" data-position="fixed" data-theme="a">
  26.     <h3>Change Password</h3>
  27.   </div>
  28. <div data-role="content">
  29.  
  30. <form name="submit" action="change-password.php" method="POST">
  31. <label for="username">Username</label>
  32. <input type="text" name="username" id="username" value=""
  33. <label for="password">Old Password</label>
  34. <input type="password" name="password" id="password" value=""
  35. data-mini="true" size="15" maxlength="15" required />
  36. <label for="newpassword">New Password</label>
  37. <input type="password" name="newpassword" id="newpassword" value=""
  38. data-mini="true" size="15" maxlength="15" required />
  39. <label for="konfirpassword">Confirm New Password</label>
  40. <input type="password" name="konfirpassword" id="konfirpassword" value=""
  41. data-mini="true" size="15" maxlength="15" required />
  42. <div data-role="fieldcontain" align="left">
  43. <input type="submit" value="submit" data-theme="c" data-role="button" name="submit"
  44. data-icon="check" data-theme="b" data-inline="true">
  45. </form></table>
  46. </div>
  47. </div>
  48. </div>
  49. </body>
  50. </html>
  51.  
  52. <?php
  53. $username = $_POST['username'];  
  54. $password = $_POST['password'];  
  55. $newpassword = $_POST['newpassword'];  
  56. $konfirmpassword = $_POST['konfirpassword'];  
  57. $submit = $_POST['submit'];
  58. $result = mysql_query("SELECT * FROM tbl_user WHERE username='$username' and password='$password'");
  59. if(!$result)  
  60. {  
  61. ?>
  62.     <script language="javascript">
  63.     alert("Username Anda Salah.");
  64.     document.location="change-password.php";
  65.     </script>
  66. <?php
  67. //echo "The username you entered does not exist";  
  68. }  
  69. else if($password!= mysql_result($result, 0))  
  70. {  
  71. ?>
  72.     <script language="javascript">
  73.     alert("Password Anda Salah.");
  74.     document.location="change-password.php";
  75.     </script>
  76. <?php
  77. //echo "You entered an incorrect password";  
  78. }
  79. else if ($newpassword!=$konfirpassword)  
  80. {
  81.     ?>
  82.     <script language="javascript">
  83.     alert("Password Anda Tidak Sama.");
  84.     document.location="index.php";
  85.     </script>
  86.     <?php  
  87. }
  88. else
  89. {
  90.     $sql=mysql_query("UPDATE user SET password='$newpassword' where username='$username'");  
  91.     if($sql)  
  92.     {
  93.          ?>
  94.         <script language="javascript">
  95.         alert("Password Berhasil diganti.");
  96.         document.location="index.php";
  97.         </script>
  98.         <?php      
  99.     }
  100. }    
  101. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement