Cannot detect non-existent parameter in $_POST (PHP 5.1.4)
Posted: Fri May 19, 2006 4:54 am
Hi All - new user here
I have the following code fragment in a PHP ASP webpage:
this is run the first time I enter my web page - it always prints "||", which means the function is returning an empty string or a null string. On the first run of the page, the POST variable 'clientid' does not yet exist until I submit the form which is at the bottom of this page.
So why is the function not returning "<none>" as it is designed to do?
Leo
Pllease help - I'm getting seriously desperate (I've wasted a whole worksday on this problem
) and am beginning to think I should switch to VBScript 
I have the following code fragment in a PHP ASP webpage:
Code: Select all
function getFromForm($p) {
$x = $HTTP_POST_VARS[$p]; //or $_POST[$p] or $HTTP_GET_VARS[$p] or $_GET[$p],
if (is_null($x)) return "<none>";
if ($x == "") return "<none>";
return $x;
}
$x = getFromForm("clientid");
echo "|".$x."|";this is run the first time I enter my web page - it always prints "||", which means the function is returning an empty string or a null string. On the first run of the page, the POST variable 'clientid' does not yet exist until I submit the form which is at the bottom of this page.
So why is the function not returning "<none>" as it is designed to do?
Leo
Pllease help - I'm getting seriously desperate (I've wasted a whole worksday on this problem