when we use header for redirecting, it will be redirect immediatelly. so how can page is wait after the redirct another location.
I am request to all of u, if you have any suggession or code, please help me.

Rgds.
Dheeraj

You can use sleep function before header('Location:http://xyz.com'). If just microsecond, then use usleep.

Thank you zippee


Rgds.
dheeraj

You may also want to have a holding page which has a meta refresh on it. This is a strategy used on forums and a great many sites.

Hi,

I am using this code to redirecting another page. But still, it is not working.

 <?php 
         if(!$sql){
        echo 'There has been an Error for Submitting your request. Please Contact the Web Master.';
         }else{
        echo "Hello <u><b>".$name."</b></u>";
         echo '<br/><hr>Thank you';
        echo '<br/><br/>Your Request is under process. Our Representative will get in touch with you.';
         sleep(5);
        echo '<script><!-- window.location= "http://www.widecomindia.com/home.html" //--></script>';
//            header("Location: http://www.widecomindia.com/home.html");
         }

if u have any example or suggession, please given reply.

Rgds.

Dheeraj

Hi Dheeraj - it's bad form to PM when you've already got a thread going...

the problem is that you're using window.location not meta refresh. Search google. There are plenty of sites showing how to do it.

<?php
if(!$sql){
echo 'There has been an Error for Submitting your request. Please Contact the Web Master.';
}else{
echo "Hello <u><b>".$name."</b></u>";
echo '<br/><hr>Thank you';
echo '<br/><br/>Your Request is under process. Our Representative will get in touch with you.';
sleep(5);
echo '<script><!-- window.location= "http://www.widecomindia.com/home.html" //--></script>';
// header("Location: http://www.widecomindia.com/home.html");
}

You cannot use php to send a http redirect header after you have sent output to the browser.
This is limited by the http protocol.

You will have to use javascript, or the meta refresh method.

JS:

<script>
<!--
timeout = '5000'; // milliseconds/1000th of a sec
window.onload = setTimeout(myRedirect, timeout); // ensure we load the whole page

function myRedirect() {

window.location = "http://www.widecomindia.com/home.html";
}
//-->
</script>

header("Refresh: 3; http://www.yourdomain.com");

Try replacing '3' with your choice. Hope it helps.

echo '<meta http-equiv="refresh" content="3; index.php" />';

Thanks i also need this.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.