Jump to content


New Members
  • Posts

  • Joined

  • Last visited

Burtonn's Achievements


Newbie (1/5)



  1. I can get the email to show for Stripe, when a user clicks the premium link at the bottom of my page, a Stripe purchase window comes up. The window will ask for the users email, credit/debit card info. I have setup the Stripe purchase window to where the user doesn't have to enter their email, it automatically has their accounts email typed out for them. I completed that task by echoing the users email in the code above, you can see where I did that on the <form> code I posted last. I now want the user to be updated when they purchase premium. I want to update them in the database by their email, considering their email will be unique. So I need help with doing this. The code I've posted above is updating users in the database by their ID, the only problem I have with that is, the only way it'll update the user by their ID is if I type the users ID at the top in SESSION. It goes the same with the email. I don't care if it updates them to premium by finding their email or ID in the database, but I want to set it where it updates that user after they purchase and only that user, without me having to type in their user id or email in the session. Basically, I want to be able to put, $user->email, or something like that and define all users, then update users in the database depending on their email, after they purchase . The only way I can update the user by email or ID is by typing it in the session myself.
  2. The above code is all I have that has to do with what I'm doing, not including all the composer files and my charge & checkout page, but they don't have anything to do with my db, just the purchase, like I said I'm not too good with php. So I could be missing a bit, let me know if I am & what, please!
  3. This is the only part I'm having problems with, I do not have anything getting the users email other than the $usersQuery / $users fetch code above, someone suggested I should use make a class, but I don't understand because I can get the users email to show up on the stripe purchase screen when they click the premium link, this is the code on my checkout page, which is the page that I can get to show the email "stripes purchase screen" <form action="charge.php" method="post"> <script src="https://checkout.stripe.com/checkout.js" class="stripe-button" data-key = "<?php echo $stripe['publishable_key']; ?>" data-name = "Blog" data-description = "Premium" data-currency = "usd" data-email = "<?php echo $users->email; ?>" data-amount = "1000"> // amount in cents </script> </form> I just can't get it to update going by the users email, I'm not new to php but I'm also not amazing with it. I could be using my code wrong, but I've tried everything.. Except the right thing haha I also could leaving a bit out, I'm not sure, but that's why I'm here. Trial & Error
  4. I'm trying to use, for example: user_email, to automatically get their email, or the get the email displayed on the purchase screen. I have stripe setup to auto display the users email they're logged in with... Once they purchase I want my DB to update the user that has the email shown on the purchase screen/the one they're logged in with... For now I have to say, another example: $_SESSION['user_id'] = '1'; or $_SESSION['user_email'] = idk@whatever.com..... Instead of me typing the users id in or the users email I want it to get it itself, like $_SESSION['user_email'] = 'users_email' or something like that but I can't get it to work and I need help with what all I should do because nothing is working for me on this
  5. I'm trying to get a users email so it will update them when they purchased premium, I'm using Stripe as my payment system. The only way I can get it to work, is if I insert their email/id into my php page. I'm wanting the page to get the users email on it's on. $_SESSION['user_id'] = 9; $stripe = array( "secret_key" => "sk_test_rDYOBYxCErhrgGCeWQJhR4mQ", "publishable_key" => "pk_test_3mIuE3OsajKO4cnFppcDDISu" ); \Stripe\Stripe::setApiKey($stripe['secret_key']); $db = new PDO('mysql:host=;dbname=blog', 'root', ''); $userQuery = $db->prepare(" SELECT id, username, email, premium FROM users WHERE id = :user_id "); $userQuery->execute(['user_id' => $_SESSION['user_id']]); $users = $userQuery->fetchObject(); I'm using ID's right now, I have to enter them on my own. The website isn't live, just testing. I can get the users email with Stripe on my checkout page by putting echo $users->email & the email shows up on the purchase screen, where normally they would have to type it. I'm not sure how to get it on purchase so it will update the user in the DB though.
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.