大家好,我一直在尝试在我的网站上添加paypal支付系统
但是当我点击提交时,重置所选的值并选择第一个,然后提交给paypal。
在这里,我希望它提交正确的选择option
。我绑几个方法但失败了。
我希望有人能帮助我解决这个问题。
我希望它在Select
中提交正确的选项。但它只提交了第一个。请修改代码并注释:)
<form id='paypal-info' method='post' action='#'>
FACEBOOK_ID</br>
<input name="fbid" value="" /></br>
<select class="form-control" value="" name="mode" id="mode">
<option value="gems">1300 Gems $5.00 USD</option>
<option value="gems1">3000 Gems $10.00 USD</option>
<option value="gems2">8000 Gems $25.00 USD</option>
<option value="gems3">17000 Gems $50.00 USD</option>
<option value="gems4">36000 Gems $100.00 USD</option>
<option value="gems5">76000 Gems $200.00 USD</option>
</select>
<input type='submit' name='pay_now' id='pay_now' value='Pay' />
</form>
<?php
if(isset($_POST['pay_now'])){
$data=array(
'merchant_email'=>'c1296562@opayq.com',
'currency_code'=>'USD',
'thanks_page'=>"http://mywebsite/tools/success.php",
'notify_url'=>"http://mywebsite/tools/cancel.php",
'cancel_url'=>"http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'],
'paypal_mode'=>true,
);
if($_POST['mode'] = gems) {
$product_name = "1300 Gems";
$amount = "5.00";
}elseif($_POST['mode']=gems1){
$product_name = "3000 Gems";
$amount = "10.00";
}elseif($_POST['mode']=gems2){
$product_name = "8000 Gems";
$amount = "25.00";
}elseif($_POST['mode']=gems3){
$product_name = "17000 Gems";
$amount = "50.00";
}elseif($_POST['mode']=gems4){
$product_name = "36000 Gems";
$amount = "100.00";
}elseif($_POST['mode']=gems5){
$product_name = "76000 Gems";
$amount = "200.00";
}
$fbid=$_POST['fbid'];
echo infotutsPaypal($data,$product_name,$amount,$fbid);
}
function infotutsPaypal( $data,$product_name,$amount,$fbid) {
define( 'SSL_URL', 'https://www.paypal.com/cgi-bin/webscr' );
define( 'SSL_SAND_URL', 'https://www.sandbox.paypal.com/cgi-bin/webscr' );
$action = '';
//Is this a test transaction?
$action = ($data['paypal_mode']) ? SSL_SAND_URL : SSL_URL;
$form = '';
$form .= '<form name="frm_payment_method" action="' . $action . '" method="post">';
$form .= '<input type="hidden" name="business" value="' . $data['merchant_email'] . '" />';
// Instant Payment Notification & Return Page Details /
$form .= '<input type="hidden" name="notify_url" value="' . $data['notify_url'] . '" />';
$form .= '<input type="hidden" name="cancel_return" value="' . $data['cancel_url'] . '" />';
$form .= '<input type="hidden" name="return" value="' . $data['thanks_page'] . '" />';
$form .= '<input type="hidden" name="rm" value="2" />';
// Configures Basic Checkout Fields -->
$form .= '<input type="hidden" name="lc" value="" />';
$form .= '<input type="hidden" name="no_shipping" value="1" />';
$form .= '<input type="hidden" name="no_note" value="1" />';
// <input type="hidden" name="custom" value="localhost" />-->
$form .= '<input type="hidden" name="currency_code" value="' . $data['currency_code'] . '" />';
$form .= '<input type="hidden" name="item_name" value="'.$product_name.'" />';
$form .= '<input type="hidden" value="_xclick" name="cmd"/>';
$form .= '<input type="hidden" name="amount" value="'.$amount.'" />';
$form .= '<input type="hidden" name="page_style" value="paypal" />';
$form .= '<input type="hidden" name="charset" value="utf-8" />';
$form .= '<input type="hidden" name="on1" value="'.$fbid.'">';
$form .= '<script>';
$form .= 'setTimeout("document.frm_payment_method.submit()", 1);';
$form .= '</script>';
$form .= '</form>';
return $form;
}
?>
答案 0 :(得分:2)
我在php代码中看到你在if语句中将其更改为==,=用于设置值但是==用于相等