gpt4 book ai didi

php - 在回显形式中发送 php 变量

转载 作者:行者123 更新时间:2023-12-01 00:19:56 25 4
gpt4 key购买 nike

当按钮被点击时,试图将一个自定义变量发送到 paypal,让自己陷入了一个困境

我目前坚持这就是我遇到的问题以及为什么交易没有正确执行

这是我的代码:

<?php
$check = $mysqli->query("SELECT is_member FROM users WHERE username = '$username'");
$row = $check->fetch_assoc();
$isMember = $row['is_member'];
if ($isMember == 0){
echo'
<p>To gain access to the members section and receive daily horse racing tips from our professionals purchase premium membership</a></p>
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="custom" value="$id;">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="CVWJZN5AALBVJ">
<input type="image" src="https://www.sandbox.paypal.com/en_US/GB/i/btn/btn_subscribeCC_LG.gif" border="0" name="submit" alt="PayPal – The safer, easier way to pay online.">
<img alt="" border="0" src="https://www.sandbox.paypal.com/en_GB/i/scr/pixel.gif" width="1" height="1">
</form>
';

}else{
echo'<p> You are a member, <a href="membership.php">click here</a> to access the membership page </p>';
}
?>

我遇到的问题是这一行:

<input type="hidden" name="custom" value="$id;">

将用户 ID 发送到 paypal。我知道如何正常执行此操作,但因为我已经回显了表单,所以我认为我不需要使用新的 php 标记来回显变量

我尝试了很多不同的传递方式,只是想得到正确的一种!

最佳答案

只是一个快速的解决方案:

像这样写那行:

'<input type="hidden" name="custom" value="' . $id . '">'

完整代码:

$check = $mysqli->query("SELECT is_member FROM users WHERE username = '$username'");
$row = $check->fetch_assoc();
$isMember = $row['is_member'];
if ($isMember == 0){
echo'
<p>To gain access to the members section and receive daily horse racing tips from our professionals purchase premium membership</a></p>
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="custom" value="' . $id . '">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="CVWJZN5AALBVJ">
<input type="image" src="https://www.sandbox.paypal.com/en_US/GB/i/btn/btn_subscribeCC_LG.gif" border="0" name="submit" alt="PayPal – The safer, easier way to pay online.">
<img alt="" border="0" src="https://www.sandbox.paypal.com/en_GB/i/scr/pixel.gif" width="1" height="1">
</form>
';

}else{
echo'<p> You are a member, <a href="membership.php">click here</a> to access the membership page </p>';
}

如果我是你,我会怎么做:

<?php
$check = $mysqli->query("SELECT is_member FROM users WHERE username = '$username'");
$row = $check->fetch_assoc();
$isMember = $row['is_member'];
if ($isMember == 0){
?>
<p>To gain access to the members section and receive daily horse racing tips from our professionals purchase premium membership</a></p>
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="custom" value="<?php echo $id; ?>">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="CVWJZN5AALBVJ">
<input type="image" src="https://www.sandbox.paypal.com/en_US/GB/i/btn/btn_subscribeCC_LG.gif" border="0" name="submit" alt="PayPal – The safer, easier way to pay online.">
<img alt="" border="0" src="https://www.sandbox.paypal.com/en_GB/i/scr/pixel.gif" width="1" height="1">
</form>
<?php

}else{
echo'<p> You are a member, <a href="membership.php">click here</a> to access the membership page </p>';
}
?>

关于php - 在回显形式中发送 php 变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33319943/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com