Login with Arabic characters
I did register and register php script. The registration part is ok with Arabic
and English characters
.
However, logging in with Arabic characters
does not work, but when it English characters
does.
Any hint of further work?
This is my code. Hope this is clear.
function login($username, $password){
$user_id = user_id_from_username($username);
$username = sanitize($username);
$password = md5($password);
return (mysql_result(mysql_query("SELECT COUNT(`user_id`) FROM `users` WHERE `username` = '$username' AND `password` = '$password'"), 0 ) == 1) ? $user_id :false;}
function user_id_from_username($username){
$username = sanitize($username);
return mysql_result(mysql_query("SELECT `user_id` FROM `users` WHERE `username` = '$username'"), 0, 'user_id');}
<?php
if (empty($_POST) === false) {
$username = $_POST['username'];
$password = $_POST['password'];
if (empty($username) === true || empty($password) === true) {
$errors[] = ' ◄ يجب آلا تكون الحقول فارغة!';
} else if (user_exists($username) === false) {
$errors[] = '◄ إسم المستخدم الذي أدخلته غير مسجل لدينا !!';
} else if (user_active($username)=== false){
$errors[] = '';
} else {
if(strlen($password) > 32){
$errors[] = '◄ كلمة المرور غير صالحة ! ';
}
$login = login($username, $password);
if ($login === false) {
$errors[] = '◄ يوجد خطاء في البيانات التي أدخلتها.. تأكد من اللغة أو حالة الأحرف !!';
}else{
//set the user session للمستخدم الحالي فقط
$_SESSION['user_id'] = $login;
// redirect user
header ('location: challengersland-cboard.php');
exit();
}
}
} else {
$errors[] = 'عذرا، لم يتم إستلام أية بيانات.';
}
if(empty($errors) === false) {
?>
<h3>▼ عذراً،حدثت الأخطاء التالية أثناء محاولتك تسجيل الدخول ▼</h3>
<?php
echo output_errors($errors);
}
?>
+3
source to share
No one has answered this question yet
See similar questions:
or similar: