【发布时间】:2019-01-23 20:38:54
【问题描述】:
所以我已经查看了与我的问题相关的答案。 我有一个 laravel 应用程序,它在我的本地主机服务器上运行良好。那里的路线运行良好。但是当我在共享主机上上传我的 laravel 应用程序时,只有 GET 方法有效。当我尝试使用任何 POST 请求(例如登录到我的应用程序)时,它会发送 405 错误代码。 所以我会告诉你我登录时出了什么问题。
这是路线。
Route::post('authinticate',['as'=>'authinticate','uses'=>'LoginController@authenticate']);
控制器功能
public function authenticate(LoginRequest $request)
{ //$credentials = $request->only('user_name', 'password');
$credentials = array(
'user_name' => $request->input('username'),
'password' => $request->input('password'),
);
if (Auth::attempt($credentials)) {
// Authentication passed...
return redirect()->route('home');
}
else{
return redirect()->back()->withErrors(['message' => 'اسم المستخدم او كلمة المرور غير صحيحين.']);
}
}
HTML 表单:
<form method="POST" action="{{ route('authinticate') }}">
@csrf
<div class="form-group signIn">
<label for="username">اسم المستخدم</label>
<input type="text" name="username" placeholder="اسم المستخدم" class="form-control" id="username" value="{{ old('user_name') }}">
</div>
<div class="form-group">
<label for="password">كلمة المرور</label>
<input type="password" name="password" placeholder="كلمة المرور" class="form-control" id="password">
<p></p>
<a href="{{ route('forgot') }}" >نسيت كلمة المرور</a>
</div>
<input type="submit" class="btn btn-block btn-default btn-success" name="submit" id="submit" value="دخـــول">
</form>
这是我在提交表单之前从控制台得到的。
Mixed Content: The page at 'https://www.aouacc.net/login' was loaded over a secure connection, but contains a form that targets an insecure endpoint 'http://www.aouacc.net/authinticate'. This endpoint should be made available over a secure connection.
【问题讨论】:
-
你能展示你的
home路由和控制器吗?您能否登录您的authenticate函数,以确保它是 1)点击该函数和 2)它将重定向到哪个?
标签: php laravel http-status-code-405