|
|
Subject:
For SGTCORY Only - PHP
Category: Computers > Programming Asked by: hammer-ga List Price: $5.00 |
Posted:
12 Dec 2003 04:34 PST
Expires: 11 Jan 2004 04:34 PST Question ID: 286290 |
I have a form which submits using PHP and method is POST. When I get a form using C for cgi, I do a check to make sure it's coming in with a POST, rather than a GET to prevent the cgi from being run directly. How do you do this in PHP? Right now, I'm checking for a required field using $_POST['field_name'] and failing if it is not present. This is working, but seems really kludgy. Could someone point me at the right way to do this? |
|
Subject:
Re: For SGTCORY Only - PHP
Answered By: sgtcory-ga on 12 Dec 2003 05:10 PST Rated: |
Hello Hammer, You would use the REQUEST_METHOD variable : Example : if ($REQUEST_METHOD == 'POST') ------------------------------------------------------------------------------- Here is an example usage. If the request came in as a POST, then the variable $uri will have all blank spaces replaced with the urlencoded '%20'. In this example, I could then safely send the request to another server without fear of a malformed request : if ($REQUEST_METHOD == 'POST') { $uri = str_replace(" ", "%20", "/test/test/test.php?k=$keyword"); } Here is more information on the PHP.net website : "Which request method was used to access the page; i.e. 'GET', 'HEAD', 'POST', 'PUT'." http://www.php.net/reserved.variables To assist with this answer I searched the PHP.net website for documentation on the variable. Thanks for the question! SgtCory |
hammer-ga
rated this answer:
and gave an additional tip of:
$1.00
Exactly what I needed. Thank you, sgtcory! |
|
Subject:
Re: For SGTCORY Only - PHP
From: sgtcory-ga on 12 Dec 2003 06:45 PST |
Thanks Hammer. Good luck with your projects! SgtCory |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
Search Google Answers for |
Google Home - Answers FAQ - Terms of Service - Privacy Policy |