PayPal IPN - Empty values on paypal site

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 for payment. My issue is when redirect to, all values empty no price or name nothing showing up. Thank you in advance!


$products = $mysqli->query("SELECT * FROM `product` WHERE `id` > '0' ORDER BY `price` ASC");
for($j=1; $product = $products->fetch_assoc(); $j++){
		<form method="post">
                    	<tr style="border-bottom:1px solid #f2f3f6;">
                            <td><input type="submit" value="Buy" name="submit" /></td>


<html xmlns="">
<head><title>redirect to paypal service..</title>
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<script type="text/javascript">
<form name="formpaypal" action="" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="<?=$sites['paypal']?>">
<input type="hidden" name="item_name" value="<?=$product['name'];?>">
<input type="hidden" name="custom" value="<?=$data['id'];?>">
<input type="hidden" name="amount" value="<?=$product['price'];?>">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="button_subtype" value="services">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="no_shipping" value="2">
<input type="hidden" name="rm" value="1">
<input type="hidden" name="return" value="index.php?success">
<input type="hidden" name="cancel_return" value="index.php?cancel">
<input type="hidden" name="notify_url" value="funtions/paypal/ipn.php">

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.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.