Guest User

Untitled

a guest
May 21st, 2018
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. include('config.php'); //My database data for connection
  2.  
  3. if(isset($_POST['submit'])) {
  4. $username = $_POST['username'];
  5. $password = $_POST['password'];
  6. $email = $_POST['email'];
  7.  
  8. $query = "INSERT INTO account SET username = '".$username."', password = PASSWORD('".$password."'), email = '".$email."'";
  9. $execute_query = mysqli_query($connection, $query);
  10. if($execute_query) {
  11. //Creates the account
  12. }
  13. else {
  14. //If an error occures
  15. }
  16. }
  17.  
  18. Username: Luís
  19. Password: 1234
  20.  
  21. Creating a DataBase and Table with:
  22. utf8_general_ci
  23. utf8_unicode_ci
  24. utf8mb4_general_ci
  25. utf8mb4_unicode_ci
  26. latin1_swedish_ci
  27.  
  28. ALTER DATABASE [name of your database] CHARACTER SET utf8;
  29.  
  30. ALTER TABLE [name of your table] CONVERT TO CHARACTER SET utf8;
  31.  
  32. ALTER TABLE [name of your table] MODIFY [name of your column] [other settings] CHARACTER SET utf8 COLLATE utf8_general_ci;
  33.  
  34. CREATE DATABASE [name of your database] CHARACTER SET utf8 COLLATE utf8_general_ci;
  35.  
  36. [client]
  37. default-character-set=utf8
  38.  
  39. [mysql]
  40. default-character-set=utf8
  41.  
  42. [mysqld]
  43. collation-server = utf8_unicode_ci
  44. init-connect='SET NAMES utf8'
  45. character-set-server = utf8
  46.  
  47. include('config.php'); //My Database data for connection.
  48. //Connection set with $connection = mysqli_connect($mysql_host, $mysql_user, $mysql_pass, $mysql_db)
  49.  
  50. if(isset($_POST['submit'])) {
  51. $username = $_POST['username'];
  52. $password = $_POST['password'];
  53. $email = $_POST['email'];
  54.  
  55. $connection->query("SET NAMES utf8"); //FIXED (Gets $connection from config.php and runs the query "SET NAMES utf8")
  56. $query = "INSERT INTO account SET username = '".$username."', password = PASSWORD('".$password."'), email = '".$email."'";
  57. $execute_query = mysqli_query($connection, $query);
  58. if($execute_query) {
  59. //Creates the account
  60. }
  61. else {
  62. //If an error occures
  63. }
  64. }
Add Comment
Please, Sign In to add comment