【问题标题】:pass a variable as integer for url将变量作为整数传递给 url
【发布时间】:2021-11-12 07:04:38
【问题描述】:

This is the index page,用户从那里被重定向到付款页面。付款完成后,我希望用户被重定向到成功页面,该页面最终重定向到已付款的“特定”项目的详细信息页面。 $customer['id'] 是一个整数值,决定了项目的唯一 id,所以如果我们可以将用户重定向到 details.php?id=$customer['id'] 就完成了。但是,我似乎无法设法找到这样做的方法。 这是我试图修改 $customer['id'] 的索引部分,以便可以通过付款页面轻松地将其传递到详细信息页面:

<?php 
  $newID = ($customer['id']); 
?>
<div class="card-action right-align"> 
  <a class="brand-text" href="payment.php">more info</a>
</div>`

这是应该重定向到的成功页面代码:

<?php
  include 'index.php';
                                    
    if(!empty($_GET['tid'] && !empty($_GET['product']))) {
      $GET = filter_var_array($_GET, FILTER_SANITIZE_STRING);
      $tid = $GET['tid'];
      $product = $GET['product'];
    } else {
      header('Location: payment.php');
    }
  ?>

  <!DOCTYPE html>
  <html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
    <title>Thank You</title>
  </head>
  <body>
    <div class="container mt-4">
      <h2>Thank you for purchasing <?php echo $product; ?></h2>
      <hr>
      <p>Your transaction ID is <?php echo $tid; ?></p>
      <p>Check your email for more info</p>
      <?php header('Refresh: 2; URL=details.php?id=$customer['id']');?>
    </div>
  </body>
</html>

在上面的代码中,这是最重要的部分(我猜必须以某种方式修改才能使其工作):

<?php header('Refresh: 2; URL=details.php?id=$customer['id']');?>

有人可以帮帮我吗?

【问题讨论】:

标签: php html sql stripe-payments


【解决方案1】:

您对那里的引号有疑问。他们在错误的地方相互抵消。在单引号之外调用变量,因为它们无法处理 php 变量。

<?php header('Refresh: 2; URL=details.php?id='.$customer['id']);?>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-04-24
    • 2021-07-28
    • 1970-01-01
    • 1970-01-01
    • 2013-01-29
    • 2017-01-06
    • 2015-05-01
    • 2018-05-17
    相关资源
    最近更新 更多