log in with Arabic characters

巧了我就是萌 提交于 2019-12-23 15:52:56

问题


I made a php registration & log-in script. Registration part is OK with Arabic and English characters.

However, Log-in with Arabic characters in not working while with English characters, it works.

Any hint for me to proceed please?

This is my code. I hope it 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);
}
?>

来源:https://stackoverflow.com/questions/29910894/log-in-with-arabic-characters

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!