notify_url.php
<?php
include('connection.php');
$sql = "UPDATE tablename
SET credit = credit + {$_POST['amount']}
WHERE username = '123456789'";
mysqli_query($con, $sql);
?>
form html
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="6RNT8A4HBBJRE">
<input type="image"
src="https://www.sandbox.paypal.com/en_US/i/btn/btn_buynowCC_LG.gif"
border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.sandbox.paypal.com/en_US/i/scr/pixel.gif"
width="1" height="1">
<input name="amount" value=10.95 type="hidden"> <<< not sure if this line should be here
<input name="notify_url" value="notify_url.php" type="hidden">
</form>
The above code is what I have in my notify_url.php file. My database is not being updated :(. My connection file is ok. And when I put a number instead of the POST variable it works fine. Which only means that my POST variable could be wrong or the script is not being called at all!
Edit: The second code is the form that was generated from PayPal website (the Buy button).