0

I have a login form with UTF-8 and i've searched online for an hour now, couldn't find anything.

I'm trying to use Hebrew for a site I'm making, here's what I've found online by now (It obviously didn't work for me). Note: it works perfectly fine with English and only when I use hebrew it gives me the following errors:

Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given

Notice: Trying to get property of non-object

PHP script I've made by now(only a small part of it):

$db_ip = "localhost";
                    $db_password = "";
                    $db_user = "root";
                    $db_name = "users";

                    $sql = mysqli_connect($db_ip , $db_user , $db_password);
                    if (!$sql) {

                        echo "Error: Unable to connect to the database." . PHP_EOL;
                        echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL;
                        echo "Debugging error: " . mysqli_connect_error() . PHP_EOL;


                    } else {
                            mysqli_query($sql , "SET character_set_results=utf8");
                            mb_language("uni");
                            mb_internal_encoding("UTF-8");
                            mysqli_select_db($sql , "users");
                            mysqli_query($sql , "set names 'utf8'");
                            $password = $_POST['password'];
                            $emailuser = $_POST['unameemail'];
                            $password = mysqli_real_escape_string($sql , $password); 
                            $emailuser = mysqli_real_escape_string($sql , $emailuser); 

                            $pwcheck = "
                            SELECT * FROM private AS p 
                            INNER JOIN user_private_data 
                            AS c ON p.id = c.id 
                            WHERE username='$emailuser' OR email='$emailuser'"; 
                            $resultcheck = mysqli_query($sql , $pwcheck);  
                            if (mysqli_num_rows($resultcheck) > 0) {
                                $rowcheck = mysqli_fetch_array($resultcheck , MYSQLI_ASSOC);
                                $hash = $rowcheck['password']; 
                                $hash_pwd = password_verify($password , $hash);
                            } else {
                                $hash_pwd = 0;
                            }
                            if ($hash_pwd != 0) {
                                $_SESSION['username'] = $rowcheck['username']; 
                                $_SESSION['logged'] = true; 
                                header("refresh:0;url=../nahomsudaibaam.php;Content-Type: text/html; charset=utf-8");      
}

this is my form:

<form action="login1.php" method="post" id="loginform" accept-charset="UTF-8">
                <div style="vertical-align: top;" dir="rtl">
                    <label dir="rtl" class="labels">שם משתמש/אימייל</label>
                    <br>
                    <br>
                    <input name="unameemail" id="username" id="unamein" type="text">
                </div>
                <div style="display: block;vertical-align:top;" dir="rtl">
                    <br>
                    <label dir="rtl" class="labels">סיסמה</label>
                    <br>
                    <br>
                    <input name="password" id="passwordin" type="password">
                </div>
                <div>
                <br>
                    <br>
                    <br>
                    <input type="submit" name="submit" value="התחבר" class="btn">
                </div>
            </form>
guy
  • 33
  • 4
  • The error itself is likely because `$resultcheck` is `false`, due to the query failing. This normally because there is a SQL error. Debug `$pwcheck` to see what the generated SQL looks like, and also what does `$emailuser` look like after it gets sent from the form? – BadHorsie Feb 09 '17 at 13:17
  • You need to check for query errors first. You're just assuming you got a `mysqli_result` back, when the query failed and you simply got a `false` instead – Machavity Feb 09 '17 at 13:18
  • how come it works with english though I find that pretty odd – guy Feb 09 '17 at 13:22
  • found the error! thanks guys – guy Feb 09 '17 at 13:28

0 Answers0