Advertisement
Guest User

Untitled

a guest
Mar 18th, 2016
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.59 KB | None | 0 0
  1. <?php
  2. session_start();
  3. if (!isset($_SESSION["user_login"])) {
  4. header("Location: sign_up.php");
  5. } else {
  6. $username = $_SESSION["user_login"];
  7. }
  8.  
  9. include ("connect.php");
  10.  
  11. ?>
  12. <!doctype html>
  13. <html>
  14. <head>
  15. <title>Change Password</title>
  16.  
  17.  
  18. <meta charset="utf-8">
  19. <link rel="stylesheet" type="text/css" href="css/index.css">
  20. <meta name="viewport" content="width=device-width, initial-scale=1">
  21. <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
  22. <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
  23. <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
  24.  
  25. </head>
  26. <body>
  27.  
  28. <div class="whole_page_div" style="width:100%; height:935px;">
  29. <div class="container-fluid" style="margin-top: 15px;">
  30. <div class="row">
  31. <div class="col-md-12">
  32. <div class="logo" style="margin-left: 750px;"><a href="index.php"><img class="logo" src="images/logo.png"/></a></div>
  33. <a href="includes/logout.php"> <button type="submit" class="btn btn-primary" name="logout" value="Log out" style="background-color:#337AB7; margin-top: -130px; margin-left: 1600px;">Log Out</button></a>
  34.  
  35. </div>
  36.  
  37.  
  38. <hr>
  39. <nav class="navbar navbar-default navbar-fixed-top topnav" role="navigation">
  40. <div class="container topnav">
  41.  
  42.  
  43. <div class="navbar-header">
  44. <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
  45. <span class="sr-only">Toggle navigation</span>
  46. <span class="icon-bar"></span>
  47. <span class="icon-bar"></span>
  48. <span class="icon-bar"></span>
  49. </button>
  50. <a class="navbar-brand topnav" href="index.php">MyAstonSpace</a>
  51. </div>
  52. <!-- Collect the nav links, forms, and other content for toggling -->
  53. <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
  54. <ul class="nav navbar-nav navbar-right">
  55. <li>
  56. <a href="#Home">Home</a>
  57. </li>
  58. <li>
  59. <a href="#Undergraduate Information">Undergraduate Information</a>
  60. </li>
  61. <li>
  62. <a href="#Post-Grad Information">Post-Grad Information</a>
  63. </li>
  64. <li>
  65. <a href="#International Students">International Students</a>
  66. </li>
  67. <li>
  68. <a href="#Contact Us ">Contact Us </a>
  69. </li>
  70. </ul>
  71. </div>
  72. <!-- /.navbar-collapse -->
  73. </div>
  74. <!-- /.container -->
  75. </nav>
  76.  
  77.  
  78. <!---------Change password------>
  79. <?php
  80. $submit_password = @$_POST['change_pass_submit'];
  81.  
  82. $oldpassword = @$_POST['oldpassword'];
  83. $newpassword1 = @$_POST['newpassword1'];
  84. $newpassword2 = @$_POST['newpassword2'];
  85.  
  86. if ($submit_password){
  87.  
  88. $pass_query = mysqli_query ($connect, "SELECT * FROM users WHERE email='$login_user'");
  89. while ($row = mysqli_fetch_assoc($pass_query)) {
  90.  
  91. $existing_pass = $row ['password'];
  92.  
  93. //Checking if md5 encrypted password matches
  94. $md5_oldpassword = md5($oldpassword);
  95. //check if the old password and the old password entered now match
  96. if ($md5_oldpassword == $existing_pass){
  97. //check if the two new passwords match
  98. if ($newpassword1 == $newpassword2) {
  99.  
  100. $md5_newpassword = md5($newpassword1);
  101. //Query to update the password
  102. $password_update_query = mysqli_query($connect, "UPDATE users SET password='$md5_newpassword' WHERE email='$login_user'");
  103. echo "Your password has now changed!";
  104.  
  105. }
  106. else{
  107.  
  108. echo "Your new password and re entered password does not match. Please try again.";
  109. }
  110. }
  111. else {
  112. echo "Your old password does not match. Please try again.";
  113. }
  114. };
  115.  
  116. }
  117. ?>
  118.  
  119.  
  120. <div class="container">
  121. <h3> Change your Password: </h3>
  122. <form action="" method="POST" enctype="multipart/form-data" role="form">
  123. <div class="form-group">
  124. <label for="oldpassword">Old Password:</label>
  125. <input type="oldpassword" class="form-control" name="oldpassword" placeholder="Enter old password" >
  126. </div>
  127. <div class="form-group">
  128. <label for="newpassword1">New Password:</label>
  129. <input type="newpassword1" class="form-control" name="newpassword1" placeholder="Enter new password" >
  130. </div>
  131. <div class="form-group">
  132. <label for="newpassword2">New Password:</label>
  133. <input type="newpassword2" class="form-control" name="newpassword2" placeholder="Re-Enter new password" >
  134. </div>
  135. <center>
  136. <button type="submit" class="btn btn-primary" name="change_pass_submit" style=" background-color:#337AB7; color:white;">Change Password</button>
  137. </center>
  138.  
  139.  
  140. <?php
  141. include ("footer-inc.php");
  142.  
  143. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement