所以我试图使用基于laravel的登录表,这是我甚至无法与基本的PHP哈希登录进行比较的哈希。不,你不能把哈希看起来像laravel。但我使用users
来自remember_token
表。Laravel基本PHP登录集成,工作!但未能设置会话
这里是我的laravel视图代码:
<form action="http://localhost/log/index.php" method="post">
<input type="hidden" value="{{ Auth::user()->remember_token }}" name="wex">
<button type="submit" class="btn btn-default">Check</button>
</form>
正如你所看到的,我尝试后remember_token
值,将收到我的http://localhost/log/index.php
为变量。
的index.php(不使用Laravel):
<?php
include "koneksi.php";
if (isset($_POST['wex'])) {
$token = $_POST['wex'];
$query = "SELECT * FROM users WHERE remember_token = '". $token ."'" ;
$result = mysqli_query($db_link,$query);
if (mysqli_num_rows($result) != 1) {
header("Location: http://localhost/laralearn/public/login");
}
session_start();
$_SESSION['user'] = "member";
}
else{
if(!isset($_SESSION['user'])){
header("Location: http://localhost/laralearn/public/login");
}
}
?>
<html>
<head>
<title>Customer</title>
</head>
<body>
<table cellpadding="5" cellspacing="5" border="1" align="center">
<tr>
<td colspan="2">If you can see this table, you are logged in. </td>
</tr>
<tr>
<td>Username:
</td>
<td><?php
while($data = mysqli_fetch_array($result))
{
echo "$data[name]";
}
?></td>
</tr>
<tr>
<td>
Token:
</td>
<td>
<?php echo $token; ?>
</td>
</tr>
</table>
</body>
</html>
变量和页面重定向如果remember_token
是无效的(工作),但我不能设置会话。该页面不断重定向到Laravel站点。
你能告诉我我在哪里做错了什么?如果你解释它并告诉我代码应该是什么样子,那将会很好。
谢谢。
你有laravel在服务器上?如果是这样,你应该能够引导(启动)laravel并使用它的身份验证 – JimL
我不想尝试在Laravel上启动会话,我试图根据laravel站点发布的消息在nonlaravel网站上启动会话。 –
我明白了,我只是说如果这个非laravel脚本是在同一台服务器上,最简单的事情就是“钩入”laravel并使用它的方法进行身份验证等。 – JimL