Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I navigate to another page when PHP script is done?

Tags:

I have a simple POST script that I need to return to the page that was doing the Posting.

Is there any way to do it like this?

if($done)
    {
        //go to page
    }
like image 498
nkcmr Avatar asked Jan 10 '11 04:01

nkcmr


People also ask

How automatically redirect to another page in PHP?

Answer: Use the PHP header() Function You can simply use the PHP header() function to redirect a user to a different page. The PHP code in the following example will redirect the user from the page in which it is placed to the URL http://www.example.com/another-page.php . You can also specify relative URLs.

How redirect same page after submit in PHP?

You should redirect with a location header after every post, because otherwise when the user presses the refresh button, it will send again the same form... Btw. if you want to do proper work, you should try out a php framework instead of this kind of spaghetti code...

Which function in PHP is used to redirect from one page to another page?

The header function in PHP can be used to redirect the user from one page to another. It is an in-built function that sends raw HTTP header to the destination (client).

How do I redirect to another page in PHP w3schools?

Redirecting Browserphp header("Location: http://www.example.com/"); ?> The following command will redirect the browser window to the given location as soon as the command is executed. Please note that Location starts with capital L, some browsers might not redirect if small l is used.


1 Answers

if ($done)
{
    header("Location: /url/to/the/other/page");
    exit;
}
like image 180
Jordan S. Jones Avatar answered Oct 21 '22 12:10

Jordan S. Jones