Welcome Guest, Not a member yet? Register   Sign In
How to use parameter in redirect function
#1

As in CI4 redirect works like return redirect()->route(). I want to know How I can use a variable in redirect.

When I'm using simple route in redirect. It works.
Like
Route: $routes->get('about-us', 'Main::about_us');

return redirect('about-us')
Its work fine.

But when I use parameter in redirect it shows an error. i.e (route cannot be found while reverse-routing.)

$studentid is some string.

return redirect('Student/ViewStudentProfile/'.$studentid');

I have also tried with route but not working.
return redirect()->route('Student/ViewStudentProfile/'.$studentid) ;

My route is 
$routes->get('Student/ViewStudentProfile/(:any)' , 'backend/Student_Controller::ViewStudentProfile');

I have spend a lot of time but not found any solution.
 
Any help would be greatly appreciated.
Reply


Messages In This Thread
How to use parameter in redirect function - by waleed - 02-12-2021, 08:52 PM



Theme © iAndrew 2016 - Forum software by © MyBB