Kish77's avatar

Post to controller from raw (.php) page

I was wondering if it's possible to post a form to a Laravel controller from a regular php page in my Laravel application?

0 likes
4 replies
richardev's avatar
Level 1

It is, but you still will have to add @csrf token inside your external form. I imagine you would have to add CSRF protection token inside your form, provide full URL path to the route, that is registered inside Laravel project and then capture request with Controller you've attached to Laravel web route. Can't confirm this yet, as I haven't tried it myself, but in theory this should work. Also you should probably use Laravel API. Read more here: https://laracasts.com/discuss/channels/general-discussion/tokenmismatchexception-posting-from-outside-of-laravel

Kish77's avatar

Thank you so much I will be looking into it. I am new to laravel.

1 like
richardev's avatar

@KISH77 - Happy to help. FYI I updated my answer above with more specifics. I myself am quite new to this framework. Luckily it has good documentation and the community here is very helpful.

Kish77's avatar

@richardev The community really is. Thanks again for replying and doing so quickly!

Please or to participate in this conversation.