markhutch Posted October 6, 2012 Share Posted October 6, 2012 It's been a while since I coded PHP so I'm more than happy to admit I've made a newbie mistake somewhere - but I don't see where! If I view the following in a browser I get everything I would normally expect: http://localhost/?phpinfo=1 Including: _SERVER["REQUEST_METHOD"] GET However, when I have the following code: if ($_SERVER["REQUEST_METHOD"]=="POST") { ... I get this error: PHP Notice: Undefined index: REQUEST_METHOD in C:\Documents and Settings\Administrator\Local Settings\Application Data\ActiveState\KomodoIDE\6.1\samples\php_tutorials\guestbook.php on line 40 (The code above is line 40 of course There are SOME $_SERVER values that I can access, like SCRIPT_NAME or PATH_TRANSLATED. Just not the ones I'm trying to access. What am I missing?? This is being run on a freshly installed WampServer 2.2. Quote Link to comment https://forums.phpfreaks.com/topic/269169-_serverrequest_method-not-in-index/ Share on other sites More sharing options...
PFMaBiSmAd Posted October 6, 2012 Share Posted October 6, 2012 Your IDE is probably running php through the command line, and not the web server. Request methods, post, get,... are specific to making http requests. Quote Link to comment https://forums.phpfreaks.com/topic/269169-_serverrequest_method-not-in-index/#findComment-1383249 Share on other sites More sharing options...
markhutch Posted October 6, 2012 Author Share Posted October 6, 2012 I'm using Komodo 6. The file in question is one of its Tutorial files. I would have thought that it would be geared up to run. Maybe there's some magic setting I've not filled in correctly. Thanks for the info though. Quote Link to comment https://forums.phpfreaks.com/topic/269169-_serverrequest_method-not-in-index/#findComment-1383256 Share on other sites More sharing options...
Andy123 Posted October 7, 2012 Share Posted October 7, 2012 (edited) You could do like this: $requestMethod = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : null; if ($requestMethod == 'post') { // Post request } Or like this: if (!empty($_POST)) { // Post request } Edited October 7, 2012 by Andy123 Quote Link to comment https://forums.phpfreaks.com/topic/269169-_serverrequest_method-not-in-index/#findComment-1383448 Share on other sites More sharing options...
ignace Posted October 7, 2012 Share Posted October 7, 2012 Your IDE is probably running php through the command line, and not the web server. Request methods, post, get,... are specific to making http requests. Like PFMaBiSmAd already mentioned are you running the file under http://localhost or are you running it inside the editor Komodo? Quote Link to comment https://forums.phpfreaks.com/topic/269169-_serverrequest_method-not-in-index/#findComment-1383450 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.