If there are data returned or received by the method $_POST it will have the value process
if there are no values returned or received it will have the valuecancel
The code poses it as follows, but there is a fatal error:
Fatal error: Using $this when not in object context in C:\xampp\htdocs\PayPal\exito.php on line 48
Line 48 of the error refers to the following line of codeelse $this->action = 'cancel';
How can I fix this error, or how to create in $_POST
an true
& false
to get the following code working:?
if(!empty($_POST)) $this->action = 'process';
else $this->action = 'cancel';
switch($this->action){
case 'process':
# code...
echo "process";
break;
case 'cancel':
# code...
echo "cancel";
break;
}
A.
If you want to evaluate that the POST in general is not empty. This is one way to do it:
b.
If you receive something like this in the URL:
or like this:
Then you can retrieve the value of
action
like this:c.
If you want to evaluate any data inside the POST and according to your comment you want a boolean value. You can proceed this way.
The variable
$bolPending
will only betrue
when there is a called key inside the POSTst
and its value isPending
.