Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Working with HTTP POST variables from within Sapphire


3 Posts   2367 Views

Ryan M.

10 May 2011 at 6:56am Community Member, 309 Posts

I tried straight out using the $_POST variables in a controller, and it seemed to not work. However, using them in a non-controller file, such as its own standalone file in the root of the site dir, worked. Is there a method for working with HTTP POST in sapphire, or is there a work-around for it?

Basically, I have some data being posted to a SS site from another, external site on a different domain, and I want to build a controller that can receive and handle that data.

Thanks in advance for any tips.


10 May 2011 at 8:12am Forum Moderator, 474 Posts

There is no reason for $_POST access to not work.

In SilverStripe, you access the SS_HTTPRequest object to get request values. In your controller, they're accessed by $this->request->postVar('varName');

Ryan M.

10 May 2011 at 12:37pm Community Member, 309 Posts

Hmm, I wasn't aware of the SS_HTTPRequest object. Thanks for pointing it out, I'll give it a try now.