作者davidou (老欧 ! 月夜雪岚)
看板PHP
标题Re: [请益] 使用者帐号登入验证程式
时间Fri Jul 1 09:04:25 2011
可以再多一个session来判断 :)
: 就是不希望使用者直接用网址连到登入後网页
: 必须要透过验证画面才能连入,不知该怎麽写
: 目前程式如下:
: <?php
: $user=$_POST["yourname"];
: $pass=$_POST["yourpass"];
: if (($user=='ccsh') and ($pass=='test'))
$_SESSION["login_session"] = true; //多一行这个
: header("location:message.php");
: else{
: print "<script>alert('您输入错误');</script>";
: print "<script>history.back();</script>";
不过你这边怎会是回到上页? 你可能要改掉溜 要是直接打网址想偷溜进去的话
就没上一页拉:)
: }
: ?>
: 目前可以判断是否输入正确,输入正确就连到message.php
: 但不想让使用者直接连到message.php该怎麽写呢?
: 谢谢各位前辈的指导
然後message.php前面就要
<?php
session_start(); // 启动Session
if ($_SESSION["login_session"] != true)
header("Location:login.php"); //跳回你要登入的页面
?>
当然其他的页面可能也都要放 没登入才会跳回首页去登入
或许说不定也有其他写法拉 :)
--
只有正妹的无名才有连结价值阿..
http://www.wretch.cc/blog/fancyou
非正妹 所以没有连结价值
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 211.21.192.217
※ 编辑: davidou 来自: 211.21.192.217 (07/01 09:06)
1F:推 stator:很谢谢d大,刚po文就回了。好快 07/01 09:18