Guest User

Untitled

a guest
May 21st, 2018
235
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. E-mail: somemail@mail.com
  21.  
  22. Creating a DataBase and Table with:
  23. utf8_general_ci
  24. utf8_unicode_ci
  25. utf8mb4_general_ci
  26. utf8mb4_unicode_ci
  27. latin1_swedish_ci
  28.  
  29. ALTER DATABASE [name of your database] CHARACTER SET utf8;
  30.  
  31. ALTER TABLE [name of your table] CONVERT TO CHARACTER SET utf8;
  32.  
  33. ALTER TABLE [name of your table] MODIFY [name of your column] [other settings] CHARACTER SET utf8 COLLATE utf8_general_ci;
  34.  
  35. CREATE DATABASE [name of your database] CHARACTER SET utf8 COLLATE utf8_general_ci;
  36.  
  37. [client]
  38. default-character-set=utf8
  39.  
  40. [mysql]
  41. default-character-set=utf8
  42.  
  43. [mysqld]
  44. collation-server = utf8_unicode_ci
  45. init-connect='SET NAMES utf8'
  46. character-set-server = utf8
  47.  
  48. include('config.php'); //My Database data for connection.
  49. //Connection set with $connection = mysqli_connect($mysql_host, $mysql_user, $mysql_pass, $mysql_db)
  50.  
  51. if(isset($_POST['submit'])) {
  52. $username = $_POST['username'];
  53. $password = $_POST['password'];
  54. $email = $_POST['email'];
  55.  
  56. $connection->query("SET NAMES utf8"); //FIXED (Gets $connection from config.php and runs the query "SET NAMES utf8")
  57. $query = "INSERT INTO account SET username = '".$username."', password = PASSWORD('".$password."'), email = '".$email."'";
  58. $execute_query = mysqli_query($connection, $query);
  59. if($execute_query) {
  60. //Creates the account
  61. }
  62. else {
  63. //If an error occures
  64. }
  65. }
Add Comment
Please, Sign In to add comment