Question

I have this page,it has a php which redirect to another website.But this has an html as well which is to be shown before the redirect.Can it be done here?I want to delay the redirection for a couple of seconds show that the html content is shown for some time before the page is redirected.

    <?php
            if($app_used=='Cnojhjkct')
            {
                $redirectTo=$respL."?status=".$status."&orderID=".$orderID."&transaefNo=".$cusf_no."&payMode=".$tranype."&cardider=".$cardPrider;
                header("Location: $redirectTo");
            }
    ?>


<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="A layout example with a side menu that hides on mobile, just like the Pure website.">

<title>Transaction Response</title>
<link rel="stylesheet" href="http://yui.yahooapis.com/pure/0.3.0/pure-min.css">
<link rel="stylesheet" href="./main.css">
</head>
<body>
<div id="layout">
    <div id="main">
           <div class="header">
             <div class="pure-g-r">
        <div class="pure-u-1-4">
         <img src="./gsggd.png" alt="Peyto Lake">
         </div></div>
           <h1>Transaction Response</h1> 
        </div>
       <div class="content">            
            </div>
                  <div style="width:100%">
       <div style="margin-left:5%;width:5%;float:left;margin-right:20%;"><img src="<?php
if($message == 'successfull')
{
    echo './success.png';
}
else
{
    echo './failed.png';
}
?>"/></div>
       <div style="width:70%;float:left;"><h3>Your transaction was <?php echo $message; ?> ! Your transaction reference number for any further communication is <?php echo $cust_ref_no; ?> .</h3></div>
   </div>
   </div>
   </div>     
    </div>
</div>
</body>
</html>
Was it helpful?

Solution

You can not use HTTP location redirect to delay, because as soon as it is read it redirects,
instead you can use refresh redirect which is :

    header( "Refresh:5; url=$redirectTop", true, 303); 

OTHER TIPS

You can't do that with the "Location" header redirect, because it takes effect as soon as it's sent, and it has to be sent before any content (i.e. you can't display anything before the redirect happens).

Your best option is probably a refresh redirect. See this question: How to Redirect Page in PHP after a few seconds without meta http-equiv=REFRESH CONTENT=time

Alternatively, you could use client-side scripting to manage it (e.g. Javascript). That gives you the most control in theory, but may be disabled on some browsers.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top