0

This is the index page, from which the user is redirected to the payment page where the payment is made. Once the payment is made, I want that the user is then redirected to the success page, which eventually redirects to the details page of the "specific" item for which the payment has been made. $customer['id'] is an integer value determines the unique id of the item, so if we can redirect the user to details.php?id=$customer['id'] then the work is done. However, I can't seem to manage to find a way to do so. Here's the part of the index in which I am trying to modify $customer['id'] so that it can be easily passed to the details page through the payment page:

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

here's the success page code which is supposed to redirect to :

<?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>

amongst the above code, this is the most important part(must be modified somehow to make it work I guess):

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

can somebody help me out please?

Nikola Pavicevic
  • 21,952
  • 9
  • 25
  • 46
Raza Nayaz
  • 11
  • 4
  • Constant [FILTER_SANITIZE_STRING](https://stackoverflow.com/questions/69207368/constant-filter-sanitize-string-is-deprecated) is deprecated. Please stop using it. – Dharman Sep 24 '21 at 10:07

1 Answers1

1

You have problem with quotes in there. they cancel each other out in the wrong place. Call the variable outside single quote marks, cause they cannot process php variables.

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