Jump to content

reading material regading Request Method var order


ricmetal

Recommended Posts

interessting the fact that the POST var in REQUEST_METHOD is called before any other variable on a script, no matter where these are placed.

is this true? am i doing something wrong here?

 

im inluding a few config variables on the very top of my webpage and calling an if statement to check in a POST request has been made way after these config variable are set. yet, the REQUEST_METHOD POST if statement check (which needs some of these config variables to run successfully) fails.

 

could someone please point me to reading material on this 'read' order?

thanks

Link to comment
Share on other sites

I'm not sure I follow? $_SERVER['REQUEST_METHOD'] contains a string. This value is define before any of your code runs, but any uses of it will only be evaluated in line with the normal flow. There's no special parsing of it, to the best of my knowledge.

 

I would guess the problem lies elsewhere in your logic. Can you post an example reproducing the issue you're talking about?

Link to comment
Share on other sites

hi, yeah

i'm running an if statement to include a php script, depending on if $_SERVER['REQUEST_METHOD'] equals POST. this included php script needs the config variables i was talking about, include at the top of the page. and this if statement is called after these config vars are included.

 

the included php script which is included due to the server request method being post needs the config variables, yet it appears it doesn't find them, like they don't exist yet. also, if i run a print in this included php script, and another in the config vars php file included at the top of the page, the print that appears first is the included php script from the server method request if statement.

 

something like

include 'config.php'; // holds variables and the print statement // outputs 'config vars here'
if($SERVER['REQUEST_METHOD' == 'POST']) { include 'anotherPHPscript.php'; } // holds a print  that outputs 'server request method queried<br>'

my webpage has a form submit button that submits to the same webpage.

 

the output of the above, on submit is:

server request method queried
config vars here

 

so this should not be happening you say?

regards

Link to comment
Share on other sites

I don't really understand what your asking but I can see straight away your code has errors.

 

1) $SERVER is non-existent unless you've created it. I'll assume you mean $_SERVER with an underscore.

2) Your trying to compare something inside the array index identifier section of your code: $SERVER['REQUEST_METHOD' == 'POST'].  This should read as follows:

 

$_SERVER['REQUEST_METHOD'] == 'POST'

Link to comment
Share on other sites

yeah

cpd

two type mistakes in the post. sorry bout that.

 

i've made a simple example of what im trying to do, and it runs fine so there must be something i'm missing in my code thats producing the issue i am having.

back to the choping block.

 

regards

Link to comment
Share on other sites

^ What CPD said.

 

Despite those errors though, there's still no reason why 'anotherPHPscript.php' would be executed first. Is that the exact code you have?

 

Edit: seen your latest post. I would suggest posting the exact code.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.