( ! ) Warning: include(): http:// wrapper is disabled in the server configuration by allow_url_include=0 in D:\www\up\php\php_03.php on line 24
Call Stack
#TimeMemoryFunctionLocation
10.0000355696{main}( )...\php_03.php:0

( ! ) Warning: include(http://pub.houheaven.com/Nav02/Nav_deep2.htm): failed to open stream: no suitable wrapper could be found in D:\www\up\php\php_03.php on line 24
Call Stack
#TimeMemoryFunctionLocation
10.0000355696{main}( )...\php_03.php:0

( ! ) Warning: include(): Failed opening 'http://pub.houheaven.com/Nav02/Nav_deep2.htm' for inclusion (include_path='.;C:\php\pear') in D:\www\up\php\php_03.php on line 24
Call Stack
#TimeMemoryFunctionLocation
10.0000355696{main}( )...\php_03.php:0

在某服务器主机上的网站根目录是webroot,网站文件结构如下:

  • public/login.php
  • music/mmm.php
  • words/www.php
  • flash/fff.php

模拟流程:mmm.php、www.php、fff.php 三个网页都有一个指向 login.php 的链接,login.php 中含有表单,用户输入信息后使用POST方式再提交信息给自身,login.php连接数据库取出数据对提交的用户信息进行验证,验证成功后,使用Cookie写入本地,然后网页自动返回原网页,从而实现一次登录全网站通行。同理,注销也是。

本网页只讲如何返回原网页,其余知识自行领会。

方法一:

<?php

echo "<script type='text/javascript'>history.go(-2);</script>";

?>

这个方法有一个小缺点,因为这种返回只是相当于直接后退,网页未经刷新,而Cookie设置后需要刷新一下原网页才能生效,所以返回到的原网页表面上看依旧是未登录状态,需要刷新一次才能显示为登录状态。

方法二:

mmm.php、www.php、fff.php:

<?php

$url=urlencode("http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']");

?>

<a href="../public/login.php?url=$url">登录</a>


login.php:

<?php

$url=$_GET['url'];

echo "<script type='text/javascript'>location.href=$url;</script>";

?>

显示框架
显示框架
显示框架
显示框架