I’ve had a look through several posts here and on forums – however I can’t figure this out, I have database table with user info and the username has some swedish characters – Ä
I’ve followed through a few guides but can’t seem to make this work any way, my mysql table is set to utf-8 swedish, row looks like the following
(`username`, `password`) VALUES('ELDMÄSTARE', '0acf4539a14b3aa27deeb4cbdf6e989f')
However when I run simple PHP login form
<?PHP
header('Content-Type: text/html; charset=utf-8');
include("config.php");
if ($_SERVER['REQUEST_METHOD'] == 'POST'){
$uname = mysql_real_escape_string(strtoupper($_POST['username']));
$pword = md5(mysql_real_escape_string($_POST['password']));
$SQL = "SELECT * FROM members WHERE username = '{$uname}' AND `password` = '{$pword}'";
$result = mysql_query($SQL);
$num_rows = mysql_num_rows($result);
if ($result) {
if ($num_rows > 0) {
$row = mysql_fetch_array($result);
$_SESSION['user'] = $row;
header ("Location: panel.php");
} else {
$errorMessage = "Error logging on";
}
}
}
head();
?>
<P><?= $errorMessage;?></P>
<FORM NAME="form1" METHOD="POST" ACTION="index.php" accept-charset="utf-8">
<table>
<tr>
<td>Username</td>
<td><INPUT TYPE= 'TEXT' Name='username' value="<?= $_POST['username'];?>" ></td>
</tr>
<tr>
<td>Password</td>
<td><INPUT TYPE= 'password' Name='password' value="" ></td>
</tr>
<tr>
<td colspan="2"><INPUT TYPE = "Submit" Name = "Submit1" VALUE = "Login"></td>
</tr>
</table>
</FORM>
</body>
</html>
It doesn’t work… Anyone would have any ideas? The SQL output appears to be fine –
SELECT * FROM members WHERE username = 'ELDMÄSTARE' AND `password` = '0acf4539a14b3aa27deeb4cbdf6e989f'
Check something like this before the query