How can I use $_GET url variable to redirect the user?

╄→гoц情女王★ 提交于 2019-12-11 16:45:58

问题


Thank you for your time. I am completely new to PHP and have very little experience so your patience and understanding is very much appreciated.

I am trying to create an exit page which I can display to my users for 5 seconds and then send them to a third party website.

I want to do this on the fly (for example exit.php?site=google.com)

I have tried the following code but it doesn't seem to work

<meta http-equiv="refresh" content="5; url="<?php
echo 'http://www.' . htmlspecialchars($_GET["site"]) . '/';
?>"> 

Any help is much appreciated :)


回答1:


You will want to use the PHP code

header("Location: http://www.example.com/"); 

most likely. What you can try doing is this:

$url = "refresh:5; url=http://www.".$_GET['site'];
header($url)

EDIT: Sorry I forgot to add the 5 second wait time.



来源:https://stackoverflow.com/questions/17601748/how-can-i-use-get-url-variable-to-redirect-the-user

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!