How to pop up a new page in php: 1. Use the "header("Location:".PSYS_BASE_URL."user/index");" method to realize the pop-up jump; 2. Use "header("refresh: 3;url='createTag' ");".
Recommendation: "PHP Video Tutorial"
PHP implements pop-up prompt box and jumps to new page
PHP realizes returning to the previous page after popping up the prompt box
<?php echo "<script>alert('退出成功!');location.href='".$_SERVER["HTTP_REFERER"]."';</script>"; ?>
alert contains the prompt message, and href is the page that jumps after the prompt.
If the alert is garbled in Chinese, add the following code
echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />';
We can consider encapsulating it into a function to call. The following is my own encapsulated page jump function
/** * 页面跳转方法 * @param $msg 提示说明 * @param null $path 跳转路径 * @param null $parent 为ture则返回父窗口 */ function messageInfo($msg,$path=NULL,$parent=NULL){ if($parent === true){ $str="<script>alert('".$msg."');parent.location.href='".$path."‘</script>"; }else if(empty($path)){ $str="<script>alert('".$msg."');history.back()</script>"; }else{ $str="<script>alert('".$msg."');location.href='".$path."'</script>"; } echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />';//支持中文 echo $str; }
How to use: messageInfo('Operation successful!','http://www.demourl.com/product_list.php');
Other jump methods
The code is as follows:
echo "<script> alert('no loginid'); </script>"; echo "<meta http-equiv='Refresh' content=0; URL=$url>";
$url is the page to be jumped. At the same time, this can also control the jump time. The 0 after content means that the page will jump after 0 seconds.
Two direct jump methods:
The code is as follows:
header("Location:".PSYS_BASE_URL."user/index");
The code is as follows:
// echo "<script> alert('创建tag成功!'); </script>"; // header("refresh:3;url='createTag' ");
The above is the detailed content of How to pop up a new page in php. For more information, please follow other related articles on the PHP Chinese website!