duancui19840401 2014-10-18 17:47
浏览 43

php ipn自定义变量不起作用

I have this button:

 <button name="pay">BUY FOR 0.50$</button>

when clicked it inserts a payment with $0 paid, the buyer IP and an account detail into DB:

$connect->query("INSERT INTO payments(ip,payed,acc,showed) VALUES('$ip','$payed', '$s', '$h')");

   echo '
<form action="https://www.paypal.com/cgi-bin/webscr" id="formsend" method="post" target="_top">
  <input type="hidden" name="cmd" value="_xclick">
  <input type="hidden" name="business" value='.$paypal.'>
  <input type="hidden" name="lc" value="US">
  <input type="hidden" name="item_name" value="LOL ACC">
  <input type="hidden" name="amount" value="0.50">
  <input type="hidden" name="currency_code" value="USD">
  <input type="hidden" name="custom" value="<?=$ip;?>">
  <input type="hidden" name="button_subtype" value="services">
  <input type="hidden" name="no_note" value="0">
  <input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynowCC_LG.gif:NonHostedGuest">
  <input type="submit" name="sub" class="sub" />
</form>
   ';
?>

<script type="text/javascript">
    document.getElementById('formsend').submit(); // SUBMIT FORM
</script>

After that it automatically clicks a new form to go to payment, if Paypal works fine. But then on the IPN the variable custom is not passing the IP address.

This is inside the IPN verified part:

require_once("config/config.php");
$connect =  new mysqli($server['database']['host'],$server['database']['username'],$server['database']['password'],$server['database']['db']);

// PAYMENT VALIDATED & VERIFIED!

$ip = $_POST['custom'];
$check = $connect->query("SELECT * FROM payments WHERE ip='$ip' AND payed = 0");

if($check->num_rows){
  $connect->query("UPDATE payments SET payed = 1 WHERE ip = '$ip'");
}

I also tried for it to insert a random string, but that doesn't seem to work either. What am I doing wrong?

  • 写回答

1条回答 默认 最新

  • dsi36131 2014-10-18 18:04
    关注

    Since you have the <?php and ?> inside single quotes, it will not be parsed. In order to do this, you should use the string concatenation operators, like so:

    echo '<form...>
    <input type="hidden" name="custom" value="' . $ip . '">
    </form>';
    
    评论

报告相同问题?

悬赏问题

  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比