Advertisement
Guest User

Untitled

a guest
May 14th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.85 KB | None | 0 0
  1. <?php
  2. include("connect.php");
  3.  
  4. $username=$_POST["login"];
  5. $password=$_POST["password"]);
  6. $email=$_POST["email"];
  7.  
  8.   /* verifica se existe um utilizador com o mesmo nome(login) */
  9. $query = "SELECT * FROM `accounts` WHERE `login` = '{$username}'";
  10. $result= mysqli_query($query);
  11. $num=mysqli_num_rows($result);
  12. if ($num > 0)
  13.  
  14. {
  15.      /* Username already exists */
  16.      echo 'Username already exists';
  17.  }
  18.  
  19. /* verifica se os campos estao preenchidos */
  20. if (empty($_POST['login']) and empty($_POST['password']) and empty($_POST['email']))
  21.     {
  22.         echo ('Fill everything on the form');
  23.     }
  24.        
  25.     }
  26.  
  27. include ("connect.php");
  28. $insert = "INSERT INTO `basedados`.`accounts` (`login` ,`password`,`email`)
  29. VALUES ('".$username."','".$password."','".$email."')";
  30. mysqli_query($MySQL, $insert);
  31.  
  32. echo ('The account was created, you can now login!');
  33.  
  34.  
  35. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement