checking for $_POST

Discuss general development subjects that are not specific to a particular version like the versioning control system we use or other infrastructure.
Post Reply
durangod
Registered User
Posts: 8
Joined: Tue Nov 29, 2011 5:18 am

checking for $_POST

Post by durangod »

im curious why in 3.0 this works fine

Code: Select all

if(isset($_POST))
{

/**
* @ignore
*/
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
however in 3.1 i get this
Illegal use of $_POST. You must use the request class or request_var() to access input data.
i did do a search for is_set_post so i could use $request in 3.1 and 3.0 but could not find is_set_post anywhere in 3.0.

So how is that post check suppose to be written when the post feed is not comming from phpbb its comming from a normal php file? Do i need to move it under the includes?

I have no issue using the if post in my 3.0.13PL install, but 3.1.+ does not like it... can you tell me why please?

thanks :)
User avatar
DavidIQ
Customisations Team Leader
Customisations Team Leader
Posts: 1862
Joined: Thu Mar 02, 2006 4:29 pm
Location: Earth
Contact:

Re: checking for $_POST

Post by DavidIQ »

In 3.1 we've disabled super globals. You just have to check for a submit variable such as:

Code: Select all

$request->variable('submit', false, false, \phpbb\request\request_interface::POST)
Image
durangod
Registered User
Posts: 8
Joined: Tue Nov 29, 2011 5:18 am

Re: checking for $_POST

Post by durangod »

Thanks david... thats my name too... :)

its an interface to create a forum account when they sign up with the normal site.

so that var can be any var in the form such as a hidden value, because i dont like using submit

for example from a NON phpbb file i can do

Code: Select all

<input type="hidden" name="sent" value="formsent" />
and then in the phpbb file that creates the account i can do (above all the includes very first thing)

Code: Select all

if($request->variable('sent', false, false, \phpbb\request\request_interface::POST))
{

.... do something

}
does that look right to you?

will that work for both 3.0 and 3.1 or just 3.1?

im trying not to have two versions for such a small difference.

can i check the version first?

UPDATE: ok after some reading i guess version checking is out of the question which is good for me (more security is ok with me) but i guess that means i need to decide if im going to support 3.1 or not
User avatar
DavidIQ
Customisations Team Leader
Customisations Team Leader
Posts: 1862
Joined: Thu Mar 02, 2006 4:29 pm
Location: Earth
Contact:

Re: checking for $_POST

Post by DavidIQ »

durangod wrote:UPDATE: ok after some reading i guess version checking is out of the question which is good for me (more security is ok with me) but i guess that means i need to decide if im going to support 3.1 or not
Request class was not available in 3.0, but I think you figured that out already. For backwards compatibility request_var is also still available so you could probably use that instead of the request class, at least for 3.1 (3.2 will likely retire this function). Also keep in mind we will probably be ending support for 3.0 at some point in the not too distant future.
Image
durangod
Registered User
Posts: 8
Joined: Tue Nov 29, 2011 5:18 am

Re: checking for $_POST

Post by durangod »

ok thanks david, looks like i need to transcend eventually to 3.1 as well and follow the crowd. I was not aware of that. So for now i guess i can have two files one for 3.1 and one for 3.0 then retire the 3.0 when support ends, thats prob the easiest way for me. wow i just realized im going to have to convert my 3.0 sites over to 3.1 as well... ugggg it never ends lol ... :)

Thanks for the help....
Post Reply