Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP/HTML/Javascript: Automatically leave page?

I've written a some PHP that interacts with a SQL database and is just around as an intermediate between two pages.

I want a user to automatically be forced to leave that page and move to another (or even a back to previous page function)

What is the easiest way to do this? I'm happy to use PHP, HTML, or JavaScript to do it.

like image 328
Fergus Barker Avatar asked Feb 22 '26 10:02

Fergus Barker


1 Answers

From php you can use the header() function to change the location:

header("Location: newpage.html");

Just be aware that if you're using header, you can't emit any html or whitespace before you make this call unless you're buffering output. Doing so will cause warnings to the effect that headers have already been sent (there is a way to work around this).


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!