获取用户电子邮件以更新数据库 [英] Getting a users email to update the DB
问题描述
我正在尝试收到用户的电子邮件,以便在他们购买高级版时更新它们,我使用Stripe作为我的支付系统。我可以让它工作的唯一方法是,如果我将他们的电子邮件/ id插入我的php页面。我希望该页面能够让用户收到电子邮件。
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_vDYOBYxCErhrgGCeWQJhR4mQ",
"publishable_key" => "pk_test_4mIuE3OsajKO4cnFppcDDISu"
);
\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();
我现在正在使用ID,我必须自己输入它们。该网站不是现场,只是测试。我可以通过输入
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
,在我的结帐页面上通过Stripe向用户发送电子邮件&安培;电子邮件显示在购买屏幕上,通常他们必须键入它。我不知道如何在购买时获得它,所以它会更新数据库中的用户。
& 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.
推荐答案
_SESSION [' user_id'] = 9 ;
_SESSION['user_id'] = 9;
stripe = array(
secret_key => sk_test_vDYOBYxCErhrgGCeWQJhR4mQ,
publishable_key => pk_test_4mIuE3OsajKO4cnFppcDDISu
);
\Stripe\Stripe :: setApiKey(
stripe = array( "secret_key" => "sk_test_vDYOBYxCErhrgGCeWQJhR4mQ", "publishable_key" => "pk_test_4mIuE3OsajKO4cnFppcDDISu" ); \Stripe\Stripe::setApiKey(
stripe [' SECRET_KEY'跨度>]);
stripe['secret_key']);
这篇关于获取用户电子邮件以更新数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!