1. i cant login my login page while i use the encrypted password using md5().

  2. session is not working in my pages.

  3. logout button is not working.

Main_Login.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
      <meta http-equiv="Expires" content="Wed, 01 Jan 2020 00:00:01 GMT" />
      <meta http-equiv="X-UA-Compatible" content="IE=edge" />
      <meta http-equiv="Content-Script-Type" content="text/javascript" />
      <meta name="description" content="Generated by Justinmind on Wed Dec 01 20:19:31 CST 2010" />
      <title>ContractManagement_1 - Main_Login</title>
      <script>

      function closeMe()
      {
      var win=window.open("","_self");
      win.close();
      }
      </script>

    </head>
    <body>
      <div id="s-9395579f-8d99-4532-9aba-597c3123fb3f">
        <input id="screenName" type="hidden" value="Main_Login" />
        <input id="canvases" type="hidden" value="s-9395579f-8d99-4532-9aba-597c3123fb3f?t-54111db7-a054-4a0b-a1aa-0177946a18ee" />
        <link type="text/css" rel="stylesheet" href="/brando/css/screens/Main_Login.css" charset="UTF-8" />
        <link type="text/css" rel="stylesheet" href="/brando/css/templates/Template 1.css" charset="UTF-8" />
      <!--[if IE]>
        <link type="text/css" rel="stylesheet" href="/brando/css/screens/Main_Login-ie.css" charset="UTF-8" />
        <link type="text/css" rel="stylesheet" href="/brando/css/templates/Template 1-ie.css" charset="UTF-8" />
      <![endif]-->
        <div class="t-54111db7-a054-4a0b-a1aa-0177946a18ee template trigger commentable">
        </div>
        <div class="s-9395579f-8d99-4532-9aba-597c3123fb3f screen trigger commentable">
          <div id="s-Group_2">
            <div id="s-Rectangle_1" class="rectangle trigger commentable" ></div>
            <div id="s-Rectangle_2" class="rectangle trigger commentable" ></div>
            <img id="s-Image_1" class="image trigger commentable"   alt="image" src="/brando/images/0- stratechon clear logo-01.png" />
            <div id="s-Line_1" class="line trigger commentable" ></div>
            <div id="s-Line_2" class="line trigger commentable" ></div>
            <div id="s-Label_1" class="label trigger commentable" >Enterprise Management Tool</div>
            <div id="s-Label_4" class="label trigger commentable" >Copyright © Stratechon, Inc. 2010</div>
           <form name="frm" method="post" action="check_user.php">
           <input id="txtusername" class="input trigger commentable" type="text" maxlength="100" name="txtusername"  />
            <input id="txtpassword" class="input trigger commentable" type="password" maxlength="100" name="txtpassword"  />

            <div id="s-Label_5" class="label trigger commentable" >Login Name:</div>
            <div id="s-Label_6" class="label trigger commentable" >Password:</div>
            <div id="s-Button_1" class="label trigger commentable"><input type="submit" name="sub" value="Log in"></div>
            </form>
            <div id="s-Button_2" class="label trigger commentable"><input type="button" value="Close" onclick="closeMe()"></div>
            <div id="s-Label_7" class="label trigger commentable" >Login Help</div>
            <div id="s-Label_8" class="label trigger commentable" >Version 1.0.2</div>
            <div id="s-Group_1">
              <div id="s-Label_2" class="label trigger commentable" >BRANDO</div>
              <div id="s-Label_3" class="label trigger commentable" >international</div>
            </div>
          </div>
        </div>
      </div>
    </body>
  </html>

---------------------------------------------------------------------------------------

check_user.php
<?php
session_start();
$host="192.168.200.100";
$username="emt_dev";
$password="ready2go#";
$db_name="emtd101";
$tbl_name="M_USER";


mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

if(isset($_POST['sub']))
{
$myusername=$_POST['txtusername'];
$mypassword=$_POST['txtpassword'];
}

$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);



$sql="SELECT * FROM $tbl_name WHERE MUSE_NAME='$myusername' and MUSE_PWD='$mypassword'";
$result=mysql_query($sql);

$count=mysql_num_rows($result);

if($count==1)
{
session_register("txtusername");
session_register("txtpassword");
header("location:Main_Dashboard.php");
}
else

header("location:loginfailed.php")

?>

--------------------------------------------------------------------------------------

Main_Dashboard.php(redirecting page after successfull login)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml">
  <script type="text/javascript">
                    function logout(){
                <?php session_destroy();?>
            }
   </script>
    <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
      <meta http-equiv="Expires" content="Wed, 01 Jan 2020 00:00:01 GMT" />
      <meta http-equiv="X-UA-Compatible" content="IE=edge" />
      <meta http-equiv="Content-Script-Type" content="text/javascript" />
      <meta name="description" content="techbowl" />
      <title>ContractManagement_1 - Main_Dashboard</title>
    </head>
    <body>
      <div id="s-4581bea1-54a0-4c84-9f8b-dac61537afab">
        <input id="screenName" type="hidden" value="Main_Dashboard" />
        <input id="canvases" type="hidden" value="s-4581bea1-54a0-4c84-9f8b-dac61537afab?t-54111db7-a054-4a0b-a1aa-0177946a18ee" />
        <link type="text/css" rel="stylesheet" href="/brando/css/screens/Main_Dashboard.css" charset="UTF-8" />
        <link type="text/css" rel="stylesheet" href="/brando/css/templates/Template 1.css" charset="UTF-8" />
      <!--[if IE]>
        <link type="text/css" rel="stylesheet" href="/brando/css/screens/Main_Dashboard-ie.css" charset="UTF-8" />
        <link type="text/css" rel="stylesheet" href="/brando/css/templates/Template 1-ie.css" charset="UTF-8" />
      <![endif]-->
        <div class="t-54111db7-a054-4a0b-a1aa-0177946a18ee template trigger commentable">
        </div>
        <div class="s-4581bea1-54a0-4c84-9f8b-dac61537afab screen trigger commentable">
          <div id="s-Rectangle_1" class="rectangle trigger commentable" ></div>
          <img id="s-Image_1" class="image trigger commentable"   alt="image" src="/brando/images/0- stratechon clear logo-01.png" />

          <div id="s-Label_1" class="label trigger commentable" >Enterprise Management Tool</div>
          <div id="s-Button_3" class="label trigger commentable" >TOOLS</div>
          <div id="s-Button_4" class="label trigger commentable" >HELP</div>
          <p><a href="logout.php">                                                   Logout</a></p>
          <div id="s-Rectangle_2" class="rectangle trigger commentable" ></div>
          <div id="s-Label_7" class="label trigger commentable" >Enterprise Managment Dashboard</div>
          <div id="s-Rectangle_3" class="rectangle trigger commentable" ></div>
          <div id="s-Button_1" class="label trigger commentable" >Accounting</div>
          <div id="s-Button_2" class="label trigger commentable" >Broker Activity</div>
          <div id="s-Button_6" class="label trigger commentable" >Contract Management</div>
          <div id="s-Button_7" class="label trigger commentable" >Hedging Activity</div>
          <div id="s-Button_8" class="label trigger commentable" >Invoicing</div>
          <div id="s-Button_9" class="label trigger commentable" >Operations</div>
          <div id="s-Button_10" class="label trigger commentable" >Order Management</div>
          <div id="s-Button_11" class="label trigger commentable" >Programme Management</div>
          <div id="s-Rectangle_4" class="rectangle trigger commentable" ></div>
          <div id="s-Button_12" class="label trigger commentable" >Reports</div>
          <div id="s-Button_13" class="label trigger commentable" >Stock Movement</div>
          <div id="s-Button_14" class="label trigger commentable" >Trade Analytics</div>
          <div id="s-Button_15" class="label trigger commentable" ></div>
          <div id="s-Button_16" class="label trigger commentable" ></div>
          <div id="s-Button_17" class="label trigger commentable" ></div>
          <div id="s-Button_18" class="label trigger commentable" ></div>
          <div id="s-Button_19" class="label trigger commentable" ></div>
          <div id="s-Rectangle_5" class="rectangle trigger commentable" ></div>
          <div id="s-Button_20" class="label trigger commentable" ></div>
          <div id="s-Button_21" class="label trigger commentable" ></div>
          <div id="s-Button_22" class="label trigger commentable" ></div>
          <div id="s-Button_23" class="label trigger commentable" ></div>
          <div id="s-Button_24" class="label trigger commentable" ></div>
          <div id="s-Button_25" class="label trigger commentable" ></div>
          <div id="s-Button_26" class="label trigger commentable" ></div>
          <div id="s-Button_27" class="label trigger commentable" ></div>
        </div>
      </div>
    </body>
</html>
logout.php
<?php

session_start();

unset($_SESSION['username']);

header('Location:Main_Login.php');

?>

Recommended Answers

All 3 Replies

please help me

if($count==1)
{
session_register("txtusername");
session_register("txtpassword");
header("location:Main_Dashboard.php");
}

You have written session_register("txtusername");
But no where assigning value in it like $_SESSION="name";

in logout page:

unset($_SESSION);

where do you defined $_SESSION in your code..

If you got any errors, plz post here...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.