Advertisement
Guest User

Untitled

a guest
Aug 4th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.09 KB | None | 0 0
  1. //// funzione  
  2.  
  3. function change_password($nuovapass)
  4.     {
  5.     session_start();
  6.     session_regenerate_id(TRUE);
  7.     $username = $_SESSION['user'];
  8.     $prefixx = PREFIX;
  9.     $table = $prefixx."users";
  10.     $query = "UPDATE ".$table." SET password = '{$nuovapass}' WHERE username = '$username';";
  11.     mysql_query($query) or die("MySQL error: ".mysql_error());
  12.     print"Password Cambiata con successo<br>";
  13.     }
  14.  
  15.  
  16.  
  17. //// file changepassword.php
  18.  
  19.  
  20. <html>
  21. <head>
  22. <meta content="text/html; charset=ISO-8859-1"
  23. http-equiv="content-type">
  24. <title></title>
  25. </head>
  26. <body>
  27. <form method="post">
  28. <h2>Modifica Password</h2>
  29. <br>
  30. Nuova Password: <input name="nuovapass"><br>
  31. <br>
  32. Conferma Nuova Password: <input name="cnuovapass"><br>
  33. <input value="Cambia Password" type="submit">
  34. </form>
  35. </body>
  36. </html>
  37. <?php
  38. require_once("functions.php");
  39. $pass = mysql_real_escape_string($_POST['nuovapass']);
  40. $passc = mysql_real_escape_string($_POST['cnuovapass']);
  41. $nuovapass = MD5($pass);
  42. if(isset($pass) && ($passc) && ($pass === $passc))
  43. {
  44. change_password($nuovapass);
  45. }
  46. else
  47. {
  48. print"Riempire tutti i campi<br>";
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement