0

On my PHP website there is a purchase page. I am thinking of adding a thankyou.php after successfully purchasing from https://secure.shareit.com/shareit/checkout.html?productid=

How can I create a Thank You page and redirect customers to that page after successfully purchasing my product?

Alfie
  • 2,341
  • 2
  • 28
  • 45

2 Answers2

0

I am assuming that you have figured it out if the user has done payment successfully.

If it success redirect to success.php

header("Location: success.php");

If it fails redirect to error.php

header("Location: error.php");

Also, if you want to send him on the location where he started payment do this and use status to show him success/failure

header("Location: main.php?status=error") OR header("Location: main.php?status=success")

you can access this variable by doing this $_GET['status'].

  • Hello Nilesh, I am new in PHP and I am only looking for redirecting customers to my thankyou.php page after successfully purchasing. Can you please provide me complete coding and steps for the same?? – user12883408 Feb 12 '20 at 06:35
  • @user12883408 Can you explain it with some more detail? – Nilesh Gaonkar Feb 12 '20 at 06:52
  • Hey.. If you have any condition to check to the purchase done, use the header: code to redirect to the new location – Ahamed Safnaj Feb 12 '20 at 07:11
0

Here is an example. Let's say completing purchase is inserting the records to a table without any errors. Once its inserted successfully you can redirect to different page using header function.

global $DBConnect;
$Query = "INSERT INTO posts(datetime,title,category,author,image,post)
          VALUES('$DateTime','$Title','$Category','$Admin','$Image','$Post')";
$Execute = mysqli_query($DBConnect,$Query);

if($Execute){
   //Success
   header("Location: thanks-page.php");
}else{
   //Error
   header("Location: error-page.php");
 }
Ahamed Safnaj
  • 611
  • 1
  • 6
  • 18