Re: Looking for some help on web header coding.
| From: | Peter J. Schoenster | Date: | Thu, 26 Sep 2002 18:31:18 +0000 |
| Subject: | Re: Looking for some help on web header coding. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-117758@lists.php.net to get a copy of this message | ||
On 26 Sep 2002 at 10:35, Joshua Patterson wrote:
> I have been working to try and have flash MX use PHP to access a
> database but have been having issues with retrieving the post values in
> php.
>
> http://127.43.1.1/learning/checkpassword.php?password=somepassword&usern
> am e= MyUserName
> //store header values to internal defined values.
> $username = $HTTP_POST_VARS['username'];
> $password = $HTTP_POST_VARS['password'];
> //db_connect has been removed for security purposes.
You are using a GET, not a POST. I've never worried about this stuff. I
started with Perl and using the CGI.pm library I just was given the
input in a hash .. left details up to CGI.pm and I got the input no
matter how it was given. I use the following in PHP
function &ProcessFormData(&$GLOBAL_INPUT) {
$FormVariables = array();
$input = $GLOBAL_INPUT['HTTP_GET_VARS'] ?
$GLOBAL_INPUT['HTTP_GET_VARS'] : $GLOBAL_INPUT['HTTP_POST_VARS'];
foreach($input as $Key=>$Value) {
if(is_array($Value)) {
foreach($Value as $SubKey=>$SubValue) {
$FormVariables[$Key][$SubKey] =
htmlspecialchars($SubValue);
}
}else {
$FormVariables[$Key] = htmlspecialchars($Value);
}
}
return $FormVariables;
} # End ProcessFormData
You might not want to use htmlspecialchars.
Also, when I do use globals (and I hate to do that) I stick them in a
global array that gets passed around. I don't use global Yaddda
....(only very rarely). Have you ever worked on someone else's code
which has over 50 scattered files and no documentation and you need to
find out where in the heck a variable is intialiazed and modified (can
be anywhere)? Is there an easy way to handle this? Drives me nuts :)
Maybe I've just not recognized the nutcracker.
Peter