在回音表单中发送php变量
当点击按钮时,试图向paypal发送一个自定义变量,这让我有点为难 我目前坚持认为这是我遇到的问题,也是为什么事务不能正确执行的原因 这是我的代码: 我遇到的问题是这一行: 将用户ID发送到paypal。我知道如何正常地执行此操作,但因为我已经在回显表单,所以我认为不需要使用新的php标记来回显变量 我试过很多不同的传球方式,只是想得到正确的一个 只是一个快速解决方案: 这样写这句话:在回音表单中发送php变量,php,mysql,Php,Mysql,当点击按钮时,试图向paypal发送一个自定义变量,这让我有点为难 我目前坚持认为这是我遇到的问题,也是为什么事务不能正确执行的原因 这是我的代码: 我遇到的问题是这一行: 将用户ID发送到paypal。我知道如何正常地执行此操作,但因为我已经在回显表单,所以我认为不需要使用新的php标记来回显变量 我试过很多不同的传球方式,只是想得到正确的一个 只是一个快速解决方案: 这样写这句话: '<input type="hidden" name="custom" value="' . $id .
'<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>';
}
?>
只是一个快速解决方案:
这样写这句话:
'<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>';
}
?>
实现这一目标的方法有以下几种: 经典串联:
echo '<input type="hidden" name="custom" value="' . $id . '">';
使用:
使用:
如果使用Heredoc,请不要忘记将结束标签(前面没有空格)放在它自己的行上。有几种方法可以实现此目的: 经典串联:
echo '<input type="hidden" name="custom" value="' . $id . '">';
使用:
使用:
如果使用herdoc,请不要忘记将结束标签(前面没有空格)放在它自己的行上。问题是,您使用的是单引号,它只是echo->value=$id;,而不是双引号,PHP在其中搜索变量并插入它们:->value=1 因此,您可以使用双引号:而不必转义HTML双引号 回声 或者直接用点连接操作符将其连接到字符串中 回声
希望我能帮上忙,-Minding问题是您使用的是单引号,它只是echo->value=$id;,而不是双引号,PHP在其中搜索变量并插入它们:->value=1 因此,您可以使用双引号:而不必转义HTML双引号 回声 或者直接用点连接操作符将其连接到字符串中 回声
希望我能提供帮助,-Minding添加,这是因为变量在字符串中使用单引号时不会插值,只有双引号。谢谢,原来问题甚至不是id:添加,这是因为变量在字符串中使用单引号时不会插值,只有双引号。谢谢,结果发现问题甚至不是id: