-1

I have the following script as a login:

//======================================================================
// LOGIN
//======================================================================
if (mysqli_real_escape_string($mysqli, $_GET['handler']) == "login") {

    $User     = mysqli_real_escape_string($mysqli, $_GET['param2']);
    $Password = mysqli_real_escape_string($mysqli, $_GET['param3']);
    $result   = $mysqli->query("SELECT * FROM ".$Usr." WHERE Benutzer = '" . $User . "' AND Passwort = '" . $Password . "'");
    if ($result->num_rows == 0) {
        echo "Not found"; //Not successfully
    } else {
        echo "Found!"; //Successful
    }
}

Well, that works BUT.. When in my table is a user "jürgen", my login always return "Found", when I type in jürgen OR jurgen. So the ü is even with the u what is not correct. I tried to change the charset on top of my PHP-file:

$mysqli     = new mysqli($servername, $username, $password, $db);
$mysqli->set_charset("utf8");

No success. When I change a different char, it returns "Not found", so it has to be the u/ü.. How can I fix that?

Dharman
  • 30,962
  • 25
  • 85
  • 135
  • 1
    For security reasons you shuld use prepared statements to prevent SQL-Injections (https://www.php.net/manual/de/pdo.prepared-statements.php). This will probably not solve your problem, but improves your security. – waXve May 13 '20 at 06:29
  • Does this answer your question? [UTF-8 all the way through](https://stackoverflow.com/questions/279170/utf-8-all-the-way-through) – Dharman May 13 '20 at 11:44

1 Answers1

0

I fixed it. I had to change the database to utf8mb4_german2_ci, now it´s working :)