How to update users in the DB by their email

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Burton
    New Member
    • Apr 2015
    • 1

    How to update users in the DB by their email

    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.

    Code:
    $_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=127.0.0.1;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

    Code:
    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.
Working...