I'm trying to make a registration form where people will take the link and enter their information, which then gets stored in the database. Unfortunately, when I try to enter information in Arabic using the form ,it gets stored in database as an unknown chars.
I have tried the following without success.
Set the default charset in the index as follows:
<meta charset="utf-8"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
Set the default charset in the database handler page:
$cfg['DefaultCharset'] = 'utf_8'; $cfg['DefaultConnectionCollation'] = 'utf8_general_ci';
Changed the database Collation to
utf8_general_ci
Changed the table Collation to
utf8_general_ci
Exported as sql and edit the charset but I found it UTF-8 already.
Made sure that my browser unicode is set to UTF-8.
And that's an example on how it works:
<form action="signup.php" method="POST" class="form">
<input type="text" name="first"><br />
<input type="text" name="uid"><br />
<input type="date" name="dob"><br />
-
$first = $_POST['first'];
$uid = $_POST['uid'];
$dob = $_POST['dob'];
$sql = "INSERT INTO students (first, uid, dob)
VALUES ('$first','$uid', '$dob')";
$result = mysqli_query($conn, $sql);
And they're connected through a required file to connect to the db.
$cfg['DefaultCharset'] = 'utf_8';
$cfg['DefaultConnectionCollation'] = 'utf8_general_ci';
$conn = mysqli_connect("localhost", "root", "", "test2");
if (!$conn ) {
die("Connection failed: ". mysqli_connect_error());
}
No idea what's causing this and I need a fast fix.
That's how it looks: https://i.stack.imgur.com/xiQwJ.png