Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to go to new Html page from PHP script?

Tags:

html

php

After the php script is over, how do I go to another html page?

like image 763
user1244153 Avatar asked Mar 02 '12 22:03

user1244153


2 Answers

Why would you want to do that? When the page is over (which I understand as the script ended execution), it is usually sent to the client and then it can be viewed by the user. So, basically, what you are trying to do is to redirect the user after the script stopped executing.

If so, you have two solutions available:

  1. Do not output anything, and after your script stopped executing, use the header() PHP function:

    header('Location: http://example.com/some/url');
    

    where you should replace the example URL with your own.

  2. If you are outputting the HTML page and sending it gradually to the user, you can just put JavaScript redirection script at the end of the page (so after everything has been sent):

    <script>
    window.location = 'http://example.com/some/url';
    </script>
    

Does any of these solutions work for you?

like image 175
Tadeck Avatar answered Oct 05 '22 13:10

Tadeck


header('Location: /page.html');
like image 39
ceejayoz Avatar answered Oct 05 '22 13:10

ceejayoz