Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

tisuchi's avatar

Token display in search URL

I made a search item for searching user profile. Everything working perfectly but when I search my csrf_token() value displays with search url.

For example, my expected search URL is search/profile?query=suchi. But when I search, it comes with following URL- search/profile?query=suchi&_token=Za2TAprLqTXapnIsSzmvHD5OgrlQRbkaEf1HBKGi

My search controller is-

public function getProfileResult(Request $request){

    $query = $request->input('query');

    if ( !$query ) {
        return redirect()->route('home');
    }

    $profiles = User::where('uName', 'LIKE', "%{$query}%")
        ->get();


    return view('search.profile')->with('profiles', $profiles);

}

Can you please help me?

0 likes
4 replies
thomaskim's avatar
Level 41

Lol. He meant your view file / blade file.

Since this is a GET request, you don't need to pass the csrf token so just take it out of your form.

1 like

Please or to participate in this conversation.