Advertisement
Guest User

Untitled

a guest
Dec 18th, 2016
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. <?php
  2. $server_host = "host";
  3. $server_username = "username";
  4. $server_password = "password";
  5. $server_dbName = "data base name";
  6.  
  7. $player_username = $_POST ["usernamePost"];
  8. $player_password = $_POST ["passwordPost"];
  9. $player_displayName = $_POST ["displayNamePost"];
  10.  
  11. $conn = new mysqli ($server_host, $server_username, $server_password, $server_dbName);
  12.  
  13. if (!$conn) {
  14. echo "Error connecting to the server.";
  15. }
  16.  
  17. $query_code = "SELECT Username FROM users WHERE Username = '{$_POST[usernamePost]}'";
  18. $result_login = mysqli_query ($conn,$query_code);
  19. $anything_found = mysqli_num_rows ($result_login);
  20.  
  21. if ($anything_found > 0) {
  22. echo "An account with this username or display name already exsists, please choose another.";
  23. }
  24.  
  25. if ($anything_found <= 0) {
  26.  
  27. $sql = "INSERT INTO users (Username, Password, Display_Name)
  28. VALUES ('".$player_username."','".$player_password."','".$player_displayName."')";
  29. $result = mysqli_query ($conn,$sql);
  30. if ($result) {
  31. echo "You may now login.";
  32. }
  33. if (!$result) {
  34. echo "Error.";
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement