Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The main problem I see is that you are using session variables. Please note that the request that hits your PHP code will be coming directly from the PayPal server and has <strong>nothing</strong> to do with the currently logged in user.</p> <p>You need to pass the user information to PayPal so that PayPal can pass it back to your server as part of the IPN request. The other thing you can do is check some of the values coming in the IPN, for example, the payer's email address (<code>payer_email</code>) or the <code>parent_txn_id</code>, or <code>payer_id</code>.</p> <p>I'm not sure about subscriptions, but refund and cancellation IPNs will include a <code>parent_txn_id</code> that provides the txn_id of the original purchase, so you can use that to locate the user's account.</p> <p>What you need to do is make sure that when a purchase is made that you're saving all the information from the IPN and tying that by the txn_id or similar to the user's account. When the cancelation comes in, use the <code>parent_txn_id</code> or whatever value you use to locate the account in the database and then apply the change to the user's account.</p> <p>I see a number of other issues with the code above.</p> <pre><code>$query = "SELECT * FROM users WHERE username= '$_SESSION[username]' AND password = '$_SESSION[password]'"; </code></pre> <p>You need to use mysql_real_escape_string on <strong>all</strong> variables that you add into a query. You should do this:</p> <pre><code>$query = "SELECT * FROM users WHERE username='".mysql_real_escape_string($username)."' AND password = '.mysql_real_escape_string($password).'"; </code></pre> <p>Second, array references should use quotes around the key name:</p> <pre><code>$_SESSION[password] =&gt; $_SESSION['password'] </code></pre> <p>Third, you should probably be locating the user in the database by their row ID in the users table (you do have a primary key of "id" set as auto-increment, right?) instead of their username and password. After you authenticate a user, you really shouldn't be keeping their password in a session variable.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload