Could someone please help me to fix the paypal forms issue, I want to show the product in index.php and once click submit, page redirect to paypal.php to take paypal forms inputs and then redirect to paypal.com for payment. My issue is when redirect to paypal.com, all values empty no price or name nothing showing up. Thank you in advance!
I’m confused by the code. In index.php it seems that when your user hits the “Buy” button, you just redirect to the paypal.php file. Where are you storing the data showing what the customer bought, who the customer is, and how do you extract that data to populate all the hidden form variables in paypal.php?
Yes, you are right! Because when customers hits the “Buy” button and redirected to paypal.php So, all values like <?=$product['price'];?> and <?=$product['name'];?> will be empty, because these variable defined only on index.php. What I want to acheive is to keep values when redirect from index.php to paypal.php. Maybe need to do it with session? I saw a lot of websites using this trick to cache hidden form data. Please any help, or correct my codes? I really appreciate your time. Thank you.
Well, the problem is redirecting. You could store everything in a selection of $_SESSION variables, but that’s not really the first way. What I’d do is I’d change your form to have an “action=paypal.php”, then all the variables in your form will appear in paypal.php as the $_POST array, and you can then combine that with the static data such as your PayPal account details to populate the form.
Have you much background in PHP coding? With respect, the code you posted at the top seems to be just a mish-mash of unrelated ideas from separate sources. The first code doesn’t pass any data through to the second, and the second just uses lots of PHP variables that haven’t been defined anywhere. In fact I’m surprised it doesn’t throw error messages when you refer to the various array elements.
So, the first thing to do, is to modify your first code so that it submits directly instead of returning to itself and redirecting, then modify your second code to just display the contents of the $_POST array. From there, you should be able to see which elements are suitable to go in your second form.
No, I don’t have much background in PHP. Anyway, will see if I can do what you said. Thank you very much dear droopsnoot, really appreciate your time and help.