doubingguan3425 2010-01-24 12:29
浏览 18
已采纳

当我成功登录一个额外的function.session-start正在显示以及如何检查登录操作页面的会话

I have a sign-in-action-form page which accept username and password from sign-in-form. Now most of things are working fine like on sign-out if I press back button logout display and session is destroyed. But I am facing a very strange problem. When I login and if login is successful a link function.session-start is shown on this page. I have not make any href like this I don't know from where this link come but it is disturbing my page. What is this error and how I can remove it. Second thing is there any method to check session for this page. I know there would be, but listen we are starting session and assigning value to session variable when our username and password are valid and if I apply checking for this page on the onload event it will show logged out because onload I have not started session done some thing like this. I don't know much about this. But I think I have explained my problem.

sign-in-action-form.php
                $con=mysql_connect("localhost","root","");
                if(!$con)
                {
                die('Could Not Connect:'.mysql_error());
                } 

                mysql_select_db("tcs",$con);

                $usr=$_POST["username"];                 //pick username from login page
                $pwd=hash('sha1',$_POST['password']);    //pick password from login page and use hash algorithm to encrypt it

                $query="select * from employee where Username='$usr' and Password='$pwd'";  //serch that single row in which both r found
                $result=mysql_query($query,$con);


                    if ($result) 
                    {

                                $row=mysql_fetch_array($result);

                        if (($row["Username"]==$usr) && ($row["Password"]==$pwd))
                        {
                                session_start(); 
                                $_SESSION['employee']['id']=$row['User Id'];
                                $_SESSION['employee']['username']=$row['Username'];


                                echo "<font color=red>"."<h3 align=center>"."Welcome ".$_SESSION['employee']['username']."</h3>"."</font>";
                                echo "<br />"."<a href='upload_file.php'>"."<font color='white'>"."<h4>"."Up-Load Files"."</h4>"."<font>"."</a>";
                                echo "<br />"."<br />"."<a href='list_files.php'>"."<font color='white'>"."<h4>"."List All Up-Loaded Files"."</h4>"."<font>"."</a>";

                        }

                        else
                        {
                                echo "Login Not Successfull";
                        }

                    }
}

else
{
echo 'Error! Username & Password were not sent!';
}

?>

</font>
<a  href="logout_file.php"><font color="white"><h3 align="right">Sign Out</h3></font></a>
<font color="white">

</body>
</html>




 session.php

    <?php
    session_start();
    if(!isset($_SESSION['employee']))
    {
        echo "Your are Logged Out";
        exit;
    }   

else
{
echo "<blink>"."Welcome Mr.".$_SESSION['employee']['username']."</blink>";
}
?>
  • 写回答

1条回答 默认 最新

  • dongwei3172 2010-01-24 12:33
    关注

    Implement a middle step like, "You have been logged out, redirecting you to front-page"

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
  • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)
  • ¥50 mac mini外接显示器 画质字体模糊