我安装了Laravel,然后将public的index.php复制到了root并更改了index.php中的某些行。我还复制了htaccess。现在,我尝试如下创建一条路线
我尝试使用{{url('signin')}}和{{route('signin')}},但无济于事
<form action="{{ route('signin') }}" method="POST">
{{ csrf_field() }}
<div>Email: <input type="text" name="username" class="userName textboxes push-right-33"></div>
<div>Password: <input type="password" name="password" class="password textboxes"></div></br>
<div class="fpassword-section">
<a href="#" onclick="return false;" class="forgot-password">Forgot Password</a>
</div>
<div class="links">
<input type="submit" class="button button-signin signin" value="Sign In">
</div>
</form>
我的路线将是
Route::any('/signin', 'LoginContoller@authenticateUser')->name('signin');
我的控制器就像
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use DB;
use Illuminate\Support\Facades\Hash;
class LoginContoller extends Controller
{
public function index(){
return view('pages.login');
}
public function authenticateUser(Request $var){
echo "string";
}
}
验证用户不返回任何内容,而是返回404
答案 0 :(得分:0)
您传递的URL错误。您不需要通过URL公开。这是基本网址。
<form action="{{ url('signin') }}" method="POST">
或者如果您想使用路线。
<form action="{{ route('signin') }}" method="POST">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
</form>
//route.php define that route as name.
Route::post('/signin', 'LoginContoller@authenticateUser')->name('signin');