php中登录后跳转回原来要访问的页面实例

在很多网站用户先访问一个要登录的页面,但当时没有登录后来登录了,等待用户登录成功之后肯定希望返回到上次访问的页面,下面我就来给大家介绍登录后跳转回原来要访问的页面实例,最简单的办法就是直接使用 php $_SERVER['HTTP_REFERER']

如果我在A.php页面要登录,现在跳到B.php页面,我们只要在b.php中加如下代码:

  1. $url = $_SERVER['HTTP_REFERER']; 
  2. header("location:$url"); 

但是上面的办法会有很多不足,如带参数等等,但在IE浏览器下的话,假如你是通过js的location来跳转的话,那这个值是获取不到的.

下面我做一个全面点的,首先创建一个方法判断是否登录,如果没登录则

  1. protected function checkLogin() {  
  2.        if (没有登录){            
  3.        $thisurl = "http://".$_SERVER["HTTP_HOST"].$_SERVER['PHP_SELF'];//当前URL  
  4.        $thisurl = urlencode($thisurl);//这里要注意需要把获取到的url转码,不然后面不好传递URL  
  5.            redirect("http://".$_SERVER["HTTP_HOST"]."/cityosweb/default.php/Index/login?url=".$thisurl);             
  6.        }  
  7.    } 

然后在需要登录的才能反问的页面调用这个方法,代码如下:$this->checkLogin();,这样如果你没有登录则跳转到登录页面,并带上了你之前页面的url:然后获取URL提交登录,代码如下:

  1. public function login() {  
  2.         $url = $_GET['url'];  
  3.         $this->assign('url',$url);  
  4.         $this->assign('title','Login');  
  5.         $this->display('user/reg_new.html');  
  6.     } 

模板上获取到url后提交到php后台,登录后跳转到这个url ok搞定..

波比源码 – 精品源码模版分享 | www.bobi11.com
1. 本站所有资源来源于用户上传和网络,如有侵权请邮件联系站长!
2. 分享目的仅供大家学习和交流,您必须在下载后24小时内删除!
3. 不得使用于非法商业用途,不得违反国家法律。否则后果自负!
4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解!
5. 如有链接无法下载、失效或广告,请联系管理员处理!
6. 本站资源售价只是赞助,收取费用仅维持本站的日常运营所需!
7. 本站源码并不保证全部能正常使用,仅供有技术基础的人学习研究,请谨慎下载
8. 如遇到加密压缩包,请使用WINRAR解压,如遇到无法解压的请联系管理员!

波比源码 » php中登录后跳转回原来要访问的页面实例

157 评论

  1. tacrolimus price tacrolimus us purchase urso online cheap

  2. order generic salbutamol 100 mcg viagra brand viagra usa

  3. oral clomid 50mg casino near me best no deposit free spins

  4. desyrel 50mg oral suhagra pills buy aurogra 50mg pills

  5. buy lasix 100mg doxycycline us buy hydroxychloroquine without prescription

  6. deltasone 40mg canada prazosin uk order vermox 100mg generic

  7. cheap tadalafil generic Cialis samples sugarhouse casino online

  8. buy dapoxetine 30mg online cheap avana oral motilium canada

  9. esomeprazole 20mg generic brand esomeprazole purchase furosemide online cheap

  10. purchase doxycycline buy monodox pill buy generic zovirax 800mg

  11. which of the following describe a “working thesis statement”? thesis versus dissertation identify and explain the two types of thesis statements

  12. azathioprine medication brand naproxen naprosyn 250mg pill

  13. order ditropan 2.5mg pills buy trileptal pills buy trileptal 300mg without prescription

  14. cialis buy online cialis usa buy erectile dysfunction pills

  15. clomid 50mg generic clomid brand buy generic plaquenil 200mg

  16. quetiapine metabolic monitoring quetiapine uses seroquel used for anxiety

  17. is quetiapine a controlled substance quetiapine xr 300 mg cost of quetiapine without insurance

  18. order mebendazole 100mg online cheap tretinoin uk buy tadalis 10mg pill

发表评论

Hi, 如果你对这款模板有疑问,可以跟我联系哦!

联系站长
赞助VIP 享更多特权,建议使用 QQ 登录
喜欢我嘛?喜欢就按“ctrl+D”收藏我吧!♡