PHP如何实现登录后跳回登录之前的页面

版权声明:转载请注明作者和出处! 作者QQ 152910000 https://blog.csdn.net/icodestechnology/article/details/87455170

以laravel框架为例,直接上代码:

html:

<form action="/comment/destination" method="post">
{{csrf_field()}}
	<input type="hidden" name="url" value="http://{{$_SERVER['HTTP_HOST']}}{{$_SERVER['REQUEST_URI']}}">
	<input type="text" value="zhangsan">
	<input type="submit" value="submit">
</form>


controller:

public function getResource(){
    return view('home.test');

}
public function postDestination(Request $request){
    $data=$request->url;
    echo '<script>alert("登录成功");window.location.href="'.$data.'"</script>';
}

没有更多推荐了,返回首页