php - Laravel GET method for search -


i create form in laravel:

<form action="/redeem" method="get" class="sidebar-form">     <div class="input-group">       <input type="text" name="key" class="form-control" placeholder="enter voucher code">           <span class="input-group-btn">             <button type="submit" name="search" id="search-btn" class="btn btn-flat"><i class="fa fa-search"></i>             </button>           </span>     </div>   </form> 

and when try submit get:

http://localhost:8888/redeem?key=nbtgj5pzls&search= 

but need just:

http://localhost:8888/redeem/nbtgj5pzls 

also in route have:

route::get('/redeem/{key}', 'orderscontroller@redeem'); 

how redirected redeem/nbtgj5pzls form?

change route to:

route::post('/redeem', 'orderscontroller@redeem'); 

and key in controller:

public function redeem(request $request) {     $key = $request->key; 

and finally, change form:

<form action="/redeem" method="post" class="sidebar-form">     {{ csrf_field() }} 

Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -