Home  >  Article  >  Backend Development  >  How to jump from one page to other pages in php

How to jump from one page to other pages in php

王林
王林Original
2021-02-20 15:03:488356browse

php method to jump from one page to other pages: add the code [header("location:url address")] in the php script. If you want to delay the jump, the code is [header("Refresh: seconds; url=address")].

How to jump from one page to other pages in php

The operating environment of this article: windows10 system, php 7.3, thinkpad t480 computer.

Implement

<?php  
    header("location:url地址") 
?>

in PHP script code. For example, the

<?php  
header("location:helloworld.php")
?>

page will jump immediately because the header performs location redirection.

Delayed jump (for example, after successful login, there will be a few seconds of waiting time, and then jumping to other pages)

<?php  
    header("Refresh:秒数;url=地址")     
?>

For example,

<?php   
    header("Refresh:3;url=helloworld.php")
?>

The jump will be executed after 3 seconds

<?php 
    sleep(3); 
    header("location:url地址")
?>

(Learning video sharing: php video tutorial)

The sleep() method is called, and the effect is also x seconds After execution jump

Implement in js script code

1.window.location.href method

<script type="text/javascript">
  window.location.href="helloworld.php"          
</script>

Use js method to implement delayed jump

<script type="text/javascript">
  setTimeout("window.location.href=&#39;helloworld.php&#39;",3000);</script>

2.window.location.assign method Delayed jump method is the same as above

<script type="text/javascript">window.location.assign("helloworld.php");</script>

3.window.location.replace method (let the new page replace the current page, it will not be saved in the history, all You cannot use the browser to return to the original page)

<script type="text/javascript">
  window.location.replace("helloworld.php");</script>

4. The window.open method has three parameters, the first URL address. The second is the way to open a new page (such as new page _blank, _new, self jump _self), and the third is the way to open a new page, including style, location, etc.

<script type="text/javascript">
  window.open("index.php",_blank,width=300px);</script>

Use HTML script code to complete the jump

Execute the code in the 93f0f5c25f18dab9d176bd4f6de5d30e tag

Just insert this code directly

<meta http-equiv="refresh" content="3;url=&#39;helloworld.php&#39;">

Related Recommended: php tutorial

The above is the detailed content of How to jump from one page to other pages in php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn