brii
brii

Reputation: 23

Passing a Variable to URL after form is processed

I'm currently working on a returns system design that is being added on to our current e-commerce system - and i'm stuck at the part where the order number variable is being passed to the thankyou page.

At the moment, the customer goes on to an order page, clicks on the return link (which sends them to a form), which is a set url with the order number dynamically added to the url. This order number is then sent from the form to a form processor, which emails us with the details of the order.

All works fine until the redirect to the thankyou page.

on the form, I have:

if(isset($_POST['submitted']))
 {
  if($formproc->ProcessForm())
 {
  $formproc->RedirectToURL();
 }
}

and in the form processor, I have :

function RedirectToURL()
{
$orderurl = $_POST['orderno'];

    $url = 'thank-you.php?returnreq=' . $orderurl;
    header("Location: $url");
    exit;
}

However, this returns no order number in the thank-you.php page url, despite the order number being passed correctly to the processor (as it sends an email with the correct order number inside)

Thanks for looking!

Upvotes: 0

Views: 156

Answers (2)

Vincent MAURY
Vincent MAURY

Reputation: 253

Check if $_POST['orderno'] is unset in ProcessForm method

Upvotes: 1

Sudip
Sudip

Reputation: 2051

Try to send the order number as a function param

function RedirectToURL($orderurl)
{
$url = 'thank-you.php?returnreq=' . $orderurl;
header("Location: $url");
exit;
}

change also from the fn call, like

....
$formproc->RedirectToURL($_POST["orderno"]);

....

Upvotes: 0

Related Questions