Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(!isset($_POST['username'])|| !isset($_POST['password']))
- {
- ?>
- <html>
- <head>
- <title> Nuovo utente</title>
- </head>
- <body>
- <form method="POST" action"nuovo_utente.php">
- Username: <input name="username" type="text"><br>
- Password: <input name="password" type="password"><br><br>
- <input type="submit" value="Registra utente">
- </form>
- </body>
- </html>
- <?php
- }
- else
- {
- ?>
- <html>
- <head>
- <title>Nuovo utente</title>
- </head>
- <body>
- <?php
- $username=$_POST['username'];
- $password=$_POST['password'];
- if(strlen($username) !=0 && strlen($password) !=0)
- {
- $password=crypt($password,0);
- $connection=@new mysqli("localhost","root","","biblioteca");
- $query="SELECT *
- FROM utenti
- where username='$username'";
- $result=@$connection->query($query);
- if($connection->errno){
- @ $connection->close();
- die("Errore nell'esecuzione della query");
- }
- if(@$result->num_rows!=0)
- echo"L'utente $username è già presente nel database.";
- else{
- $query="INSERT INTO Utenti (username,password,DB_username,DB_password) values('$username','$password','root','')";
- $connection->query($query);
- echo"L'utente $username è stato aggiunto al database.";
- }
- @$result->free();
- @$connection->close();
- }
- else
- echo "Username/password non validi.";
- ?>
- </body>
- </html>
- <?php
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement