Guest User

Untitled

a guest
Jun 28th, 2018
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.61 KB | None | 0 0
  1. <?php
  2. session_start();
  3. require "connect.php";
  4. $username = $_SESSION['username'];
  5. $roll_no = $_SESSION['rollno'];
  6. ?>
  7. <!DOCTYPE html>
  8. <html>
  9.  
  10. <head>
  11. <meta charset="utf-8">
  12. <title><?php echo $username;?> | Password</title>
  13. <link rel="stylesheet" href="css/main.css">
  14. <link rel="stylesheet" href="css/forms.css">
  15. <style media="screen">
  16. html,body{
  17. background-image: none;
  18. }
  19. .form-contain{
  20. margin: 100px auto;
  21. width: 400px;
  22. height: auto;
  23. background-color: #ffffff;
  24. padding: 30px;
  25. text-align: center;
  26. box-sizing: border-box;
  27. border: 1px solid #ccc;
  28. }
  29. .nav{
  30. box-shadow: 0px 5px 15px #ccc;
  31. }
  32. </style>
  33. </head>
  34. <body>
  35. <header>
  36. <div class="nav">
  37. <ul>
  38. <li class="has-dropdown"><span><a href="alumni_profile.php" id="profile"><?php echo "$username"; ?></a></span>
  39. <div class="dropdown-content">
  40. <ul>
  41. <li><a href="alumni_edit_profile.php">Edit</a></li>
  42. <li><a href="alumni_edit_password.php">Password</a></li>
  43. </ul>
  44. </div>
  45. </li>
  46.  
  47. <li><span><a href="alumni_posts.php">Post</a></span></li>
  48. <li><span ><a href="alumni_chat.php">Chat</a></span></li>
  49. <li ><span ><a href="alumni_send_reports.php">Report</a></span></li>
  50. <li><span ><a href="index.php" id="log">logout</a></span></li>
  51. </ul>
  52. </div>
  53. </header>
  54. <main>
  55. <div class="form-contain">
  56. <?php
  57. $conn = new mysqli(server,username,password,database);
  58. if ($conn->connect_error) {
  59. die("Connection failed: " . $conn->connect_error);
  60. }
  61.  
  62.  
  63. if ($_SERVER["REQUEST_METHOD"] == "POST") {
  64.  
  65. $currentPassword = $_POST['password'];
  66. $newpassword = $_POST['newpassword'];
  67. $renewpassword = $_POST['renewpassword'];
  68.  
  69. $sql = "SELECT password FROM alumniStudent WHERE username = '$username' AND rollno ='$roll_no'";
  70. $result =$conn->query($sql);
  71. $row = $result->fetch_assoc();
  72.  
  73. if ($currentPassword == $row['password']){
  74.  
  75. if ($newpassword === $renewpassword) {
  76.  
  77. $edit= "UPDATE alumniStudent SET password ='$newpassword' WHERE username ='$username' AND rollno ='$roll_no'";
  78. if($conn->query($edit) === true){
  79. echo "<center><p style = 'color:red'>"."Saved"."</p></center>";
  80. }else{
  81. echo "<center><p style = 'color:red'>"."Failed"."</p></center>";
  82. }
  83.  
  84.  
  85. }else {
  86. echo "<p style = 'color:red'>"."password not match"."</p>";
  87. }
  88. }else {
  89. echo "<p style = 'color:red'>"."current password not match"."</p>";
  90. }
  91. }
  92.  
  93. ?>
  94. <form class="form-content" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="post">
  95. <div class="">
  96. <h3 style = 'color: #21d4fd'>Edit <?php echo $username;?> Possword</h3>
  97. </div>
  98. <label for="newpassword"><input type="password" name="newpassword" value="" required="required" value="" placeholder="New possword"></label><br>
  99. <label for="renewpassword"><input type="password" name="renewpassword" value="" required="required" value="" placeholder="reEnter"></label><br>
  100. <label for="password"><input type="password" name="password" value="" required="required" placeholder="current password"></label><br>
  101. <label for="login"><input type="submit" name="" value="Save"></label>
  102. </form>
  103. </div>
  104. </main>
  105. </body>
  106. </html>
Add Comment
Please, Sign In to add comment