Просмотр полной версии : Привязка по ВК
nesquik -_-
01.03.2021, 10:24
Делаю авторизацию по вк, сделал вывод user id, когда человек авторизировался, так же , создал в базе данных структуру с uid, хочу сделать так, если в этой структуре есть определенный uid , его пускало на сайт, если нету, то простой редирект на ошибку, к примеру error.php
вот мой запрос, с ним ложиться сайт
https://forum.antichat.xyz/attachments/27681413/
:
$sql = "select * from accounts where uid=$_SESSION['uid']";
$result = $mysqli->query($sql);
$rows = $result->num_rows;
так может
$sql = "SELECT * FROM accounts WHERE uid=".$_SESSION['uid'];
ты массив в запрос засунул,
code:
$session
=
$_SESSION
[
'id'
]
;
$stmt
=
$mysqli
-
>
prepare
(
"select * from accounts where uid = ?"
)
;
$stmt
-
>
bind_param
(
"i"
,
$session
)
;
$stmt
-
>
execute
(
)
;
$rows
=
$stmt
-
>
num_rows
;
Изучи это
PHP: mysqli_stmt - Manual (https://www.blast.hk/redirect/aHR0cHM6Ly93d3cucGhwLm5ldC9tYW51YWwvcnUvY2xhc3MubX lzcWxpLXN0bXQucGhw)
The mysqli_stmt class
www.php.net
А лучше это
(The only proper) PDO tutorial (https://www.blast.hk/redirect/aHR0cHM6Ly9waHBkZWx1c2lvbnMubmV0L3Bkbw)
There are many tutorials on PDO already, but unfortunately, most of them fail to explain the real benefits of PDO, or even promote rather bad practices. The only two exceptions are [phptherightway.com](http://www.phptherightway.com/#pdo_extension) and...
phpdelusions.net
vBulletin® v3.8.14, Copyright ©2000-2026, vBulletin Solutions, Inc. Перевод: zCarot