将变量作为整数传递给 url

pass a variable as integer for url

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 个变量。

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