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, Ed, biapar, Willr, Ingo, swaiba

Working with HTTP POST variables from within Sapphire

Go to End

3 Posts   4493 Views

Ryan M.

Community Member, 309 Posts

10 May 2011 at 6:56am

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.


Community Member, 473 Posts

10 May 2011 at 8:12am

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.

Community Member, 309 Posts

10 May 2011 at 12:37pm

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