Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Forward to the same controller with the same action.

I'm now writing a members system. I have a controller named "Controlpanel" with an action "loginAction" inside. If a user request "controlpanel/login" with a "get" method, and he/she would see a login form. If a "post" request is sent, I would check the database with the user name and password. If correct forward( with dispatcher->forward() ) to "controlpanel/index", otherwise forward to "controlpanel/login" again.

My Question is that: If I forward to "controlpanel/login" again, I would get a unlimited loop...... I thought it's because the user's request is forwarded to "controlplanel/login" itself with "post" but not "get". Is there any method to forward to loginAction itself but change the method to "get" ?



5.5k
Accepted
answer

Maybe you should just use redirect instead of forward to controlpanel/login. This way you method will be GET



770

Thanks! This works!! ^ ^