So I have something like this (barebone for simplicity of the question):
<?php
$paymentResult = 'Unknown';
function processPayment(){
// Process all payment values from form1 and retrieve the result of the transaction.
$GLOBALS['paymentResult'] = 'Your payment was completed successfully!';
}
?>
<form name="form1" method="POST" onsubmit="return processPayment();" action="<?php echo 'checkout_s.php?result=' . $paymentResult; ?>">
<!--Additional Credit Card Payment Controls-->
<input type="submit" value="Process Payment">
</form>
The processPayment()
method obviously has additional messages and logic in case the payment fails and etc.
My question is, no matter what I set $paymentResult
to within the processPayment()
function, it always passes 'Unknown' as the value of
the post variable when I echo $_REQUEST['result'];
on checkout_s.php.
I'm pretty confident I'm using the global variable correctly. Can somebody please offer advice on how to correctly modify the code or offer an additional method? I don't want to pass credit card information as post variables, so I'm processing it on the same page. All I want to do is pass the result of the transaction to the action page.