Advertisement
Guest User

Untitled

a guest
Mar 1st, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1.  
  2. <?php
  3. if(!isset($_POST['username'])|| !isset($_POST['password']))
  4. {
  5. ?>
  6. <html>
  7. <head>
  8. <title> Nuovo utente</title>
  9. </head>
  10. <body>
  11. <form method="POST" action"nuovo_utente.php">
  12. Username: <input name="username" type="text"><br>
  13. Password: <input name="password" type="password"><br><br>
  14. <input type="submit" value="Registra utente">
  15. </form>
  16. </body>
  17. </html>
  18. <?php
  19. }
  20. else
  21. {
  22. ?>
  23. <html>
  24. <head>
  25. <title>Nuovo utente</title>
  26. </head>
  27. <body>
  28. <?php
  29. $username=$_POST['username'];
  30. $password=$_POST['password'];
  31. if(strlen($username) !=0 && strlen($password) !=0)
  32. {
  33. $password=crypt($password,0);
  34. $connection=@new mysqli("localhost","root","","biblioteca");
  35. $query="SELECT *
  36. FROM utenti
  37. where username='$username'";
  38. $result=@$connection->query($query);
  39. if($connection->errno){
  40. @ $connection->close();
  41. die("Errore nell'esecuzione della query");
  42. }
  43. if(@$result->num_rows!=0)
  44. echo"L'utente $username &egrave; gi&agrave; presente nel database.";
  45. else{
  46. $query="INSERT INTO Utenti (username,password,DB_username,DB_password) values('$username','$password','root','')";
  47. $connection->query($query);
  48. echo"L'utente $username &egrave; stato aggiunto al database.";
  49. }
  50. @$result->free();
  51. @$connection->close();
  52. }
  53. else
  54. echo "Username/password non validi.";
  55. ?>
  56. </body>
  57. </html>
  58. <?php
  59. }
  60. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement