我尝试根据用户在下拉列表中选择的货币发布不同的订阅。菜单是:
<form action="charge.php" method="post">
<h3>Sign up to get a new quote every day! Just €400 a month! <small>(Subscription)</small></h3>
<input type="hidden" name="subscription_purchase" value="subscription_purchase" />
<input type="text" name="email" placeholder="Email Address" />
<input type="password" name="password" placeholder="Password" />
<select name="currency" value="currency" method="post">
<option value="euro">Euro</option>
<option value="dollar">USD</option>
<option value="rand">RND</option>
<option value="pounds">GBP</option>
</select>
<script
src="https://button.stripe.com/v1/button.js" class="stripe-button"
data-key="<?php echo $stripe['publishable_key']; ?>"
data-amount=40000
data-description="Wilde monthly subscription"
data-label="Checkout">
</script>
</form>
以及我要测试的条件如下:
if(isset($_POST['subscription_purchase']) && isset($_POST['currency' == 'euro']))
{
$customer = Stripe_Customer::create(array(
'card' => $_POST['stripeToken'],
'email' => $_POST['email'],
'plan' => 'monthly',
'description' => 'Subscription'
));
}
else if(isset($_POST['subscription_purchase']) && isset($_POST['currency' == 'dollar']))
{
$customer = Stripe_Customer::create(array(
'card' => $_POST['stripeToken'],
'email' => $_POST['email'],
'plan' => 'monthly_USD',
'description' => 'Subscription'
));
}
我认为错误属于if语句中的货币,但我不知道如何纠正逻辑。所以问题是if条件失败并执行此代码后面的else语句,我错过了一些东西,但没有经验可以看到它。在此先感谢Conor。