Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- include('config.php'); //My database data for connection
- if(isset($_POST['submit'])) {
- $username = $_POST['username'];
- $password = $_POST['password'];
- $email = $_POST['email'];
- $query = "INSERT INTO account SET username = '".$username."', password = PASSWORD('".$password."'), email = '".$email."'";
- $execute_query = mysqli_query($connection, $query);
- if($execute_query) {
- //Creates the account
- }
- else {
- //If an error occures
- }
- }
- Username: Luís
- Password: 1234
- E-mail: somemail@mail.com
- Creating a DataBase and Table with:
- utf8_general_ci
- utf8_unicode_ci
- utf8mb4_general_ci
- utf8mb4_unicode_ci
- latin1_swedish_ci
- ALTER DATABASE [name of your database] CHARACTER SET utf8;
- ALTER TABLE [name of your table] CONVERT TO CHARACTER SET utf8;
- ALTER TABLE [name of your table] MODIFY [name of your column] [other settings] CHARACTER SET utf8 COLLATE utf8_general_ci;
- CREATE DATABASE [name of your database] CHARACTER SET utf8 COLLATE utf8_general_ci;
- [client]
- default-character-set=utf8
- [mysql]
- default-character-set=utf8
- [mysqld]
- collation-server = utf8_unicode_ci
- init-connect='SET NAMES utf8'
- character-set-server = utf8
- include('config.php'); //My Database data for connection.
- //Connection set with $connection = mysqli_connect($mysql_host, $mysql_user, $mysql_pass, $mysql_db)
- if(isset($_POST['submit'])) {
- $username = $_POST['username'];
- $password = $_POST['password'];
- $email = $_POST['email'];
- $connection->query("SET NAMES utf8"); //FIXED (Gets $connection from config.php and runs the query "SET NAMES utf8")
- $query = "INSERT INTO account SET username = '".$username."', password = PASSWORD('".$password."'), email = '".$email."'";
- $execute_query = mysqli_query($connection, $query);
- if($execute_query) {
- //Creates the account
- }
- else {
- //If an error occures
- }
- }
Add Comment
Please, Sign In to add comment