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开发者_StackOverflow>"."<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>";
}
?>
Implement a middle step like, "You have been logged out, redirecting you to front-page"
精彩评论