Jump to content

How to make two different person checked the report


shebbycs

Recommended Posts

login.php

<?php
    session_start();
    mysql_connect("localhost","root") or die(mysql_error());
    mysql_select_db("kime") or die(mysql_error());
    $branchcodename = $_POST['branchcodename'];
    $password = $_POST['pass'];
    if (isset($_POST["submit"]))
    {
     $log3 = "SELECT Branch_Codename,Branch_Name,Branch_Password,Userlevel FROM branch_login WHERE Branch_Codename =  '$branchcodename' AND 
	          Branch_Password ='$password'";
     $login3 = mysql_query($log3);
     $row = mysql_fetch_array($login3);
     $number = mysql_num_rows($login3);

     if ($number == 0)
     {
	   echo "<script type='text/javascript'>alert('The branchcodename or password is not exists, please try login')</script>";	 
	   echo "<script type='text/javascript'>window.location = 'login.php'</script>";
     }
     if ($number > 0)
     {
		$_SESSION['ID'] = $row['ID']; 
		$_SESSION['branchcodename'] = $row['Branch_Codename'];
		$_SESSION['branchname'] = $row['Branch_Name']; 
        $_SESSION['password'] = $row['Branch_Password'];
        $_SESSION['userlevel'] = $row['Userlevel'];
        $_SESSION['is_logged_in'] = 1;
		
	  	
        if($_SESSION['userlevel']==1)
       {
         $_SESSION['is_logged_in'] = 1;
         header("Location: countercashform.php");
       }
        else if($_SESSION['userlevel']==2)
       {
         $_SESSION['is_logged_in'] = 1;
         header("Location: countercashform2.php");
       }
	    else if($_SESSION['userlevel']==0)
	   {
         $_SESSION['is_logged_in'] = 1;
         header("Location: countercashadminselect.php");
       } 
     }

   }

    else
    {
?>
<!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" />
<title>COUNTER CASH LOGIN</title>
<script type="text/javascript">
 function a()
{
   var x = document.login.branchcodename.value;
   var y = document.login.pass.value;

   if(x==""&& y=="")
   {
    alert("Please Insert Username & Password");
    return false;
   }
   if(x=="")
   {
     alert("Please Insert Username");
     return false;
   }
   if(y=="")
   {
     alert("Please Insert Password!");
     return false;
   }
}
</script>
</head>
<body>
<center>
<table border="0" align="center">
<form name="login" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" onsubmit="return a()">
<tr><td colspan=3><center><h1>Login</h1></center></td></tr>
<tr><td>Branch Codename</td><td>:</td><td><input type="text" name="branchcodename" maxlength="40"></td></tr>
<tr><td>Password</td><td>:</td><td><input type="password" name="pass" maxlength="50"></td></tr>
<tr><td colspan=3><center><input type="submit" name="submit" value="Login"></center></td>

</tr>
</form>
</center>
</body>
</html>
<?php

  }



 ?>

 

 

 

Countercashadminselect.php

<?php
session_start();
if (empty($_SESSION['is_logged_in']))
{
 header("Location:login.php");
 die();     // just to make sure no scripts execute
}
?>
<?php
 	mysql_connect("localhost","root") or die(mysql_error());
    mysql_select_db("kime") or die(mysql_error());
	$a=$_SESSION['branchcodename'];	
    $branchcodename = $_POST['branchcodename'];
    if (isset($_POST["submit"]))
    {
     $log3 = "SELECT Branch_Codename FROM branch_login WHERE Branch_Codename =  '$branchcodename'";
     $login3 = mysql_query($log3);
     $row = mysql_fetch_array($login3);
     $number = mysql_num_rows($login3);
	  if ($number == 0)
     {
      print "This user does not exist in our database. <a href=registration.php><input type='button' value='Register'></a>";
     }
     if ($number > 0)
     {
        $_SESSION['branchcodename'] = $row['Branch_Codename'];
        $_SESSION['is_logged_in'] = 1;
		$a=$_SESSION['branchcodename']; 
		$b=$_SESSION['branchname'];
		
		
        if($_SESSION['branchcodename']=="OK01")
       {
		 $sql = mysql_query("UPDATE counter_cash SET Check_By = '$b'");
         $_SESSION['is_logged_in'] = 1;
		 header("Location: countercashadminview.php");
       }
        else if($_SESSION['branchcodename']=="TK02")
       {
         $_SESSION['is_logged_in'] = 1;
         header("Location: countercashadminview2.php");
       }
	  
     }

   }

    else
    { 
?>
<!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" />
<title>Untitled Document</title>
<script type="text/javascript">
 function a()
{
  var x = document.select.branchcodename.value;

  if(x=="")
  {
   alert("Please choose branch location");
   return false;
  }
}
</script>
</head>
<body>
<center>
<table border="0" align="center">
<form name="select" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" onsubmit="return a()">
<tr><td><center><h1>CHOOSE COUNTER CASH CHECKING REPORT LOCATION</h1></center></td></tr>
<tr><td><center>Branch Codename:<select name="branchcodename">
                                <option value="OK01">OK</option>
                                <option value="TK02">TK</option>
                                </select></center></td></tr>
<tr><td><center><input type="submit" name="submit" value="Submit"></center></td></tr><tr><td><center><h2><a href="admineditprofile.php?id=<?php echo $a;?> ">Edit</a></center></h2></td>
</tr>

</form>
</table>
</center>
</body>
</html>
<?php  

 }



countercashadminview.php

<?php
 session_start();
 mysql_connect("localhost","root") or die ("could not connect to the mysql");
 mysql_select_db("kime") or die ("no database");
 $a=$_SESSION['branchcodename'];
 $b=$_SESSION['branchname'];
 $sql1 = mysql_query("SELECT * FROM counter_cash ORDER BY Date") or die(mysql_error());
 echo "<center><h2>COUNTER CASH CHECKING REPORT</h2>";
 echo "<table><tr><td><h3>LOCATION</h3></td><td><h3>:</h3></td><td><h3>".$a."</h3></td></tr></table></center>";
 echo "<center><table border = '1'>";
 echo "<tr><th rowspan='2'>DATE & TIME</th><th rowspan='2'>CASHIER NAME</th><th colspan='3'>COUNTER CASH</th><th colspan='3'>PETTY CASH</th><th  rowspan='2'>SIGN</th><th  
 rowspan='2'>HANDOVER TO (NAME)</th><th rowspan='2'>SIGN</th><th rowspan='2'>CHECK BY</th></tr>";	 
 echo "<tr><th>AMOUNT</th><th>SHORTAGE</th><th>EXCESS</th><th>AMOUNT</th><th>SHORTAGE</th><th>REMARK</th></tr>";
 while($report = mysql_fetch_array($sql1))
 {
  echo "<tr align='center'><td>".$report['Date']."</td> ";
  echo "<td>".$report['Cashier_Name']."</td> ";
  echo "<td>RM  ".$report['Counter_Amount']."</td> ";
  echo "<td>RM  ".$report['Counter_Shortage']."</td> ";
  echo "<td>RM  ".$report['Counter_Excess']."</td> ";
  echo "<td>RM  ".$report['Petty_Amount']."</td> ";
  echo "<td>RM  ".$report['Petty_Shortage']."</td> ";
  echo "<td>".$report['Petty_Remark']."</td> ";
  echo "<td>".$report['Cashier_Sign']."</td> ";
  echo "<td>".$report['Handover_Name']."</td> ";
  echo "<td>".$report['Handover_Sign']."</td> ";
  echo "<td>".$report['Check_By']."</td> ";
 }
 echo"</table><h3><a href='countercashadminselect.php'>BACK</a>       <a href='logout.php'>LOG OUT</a></h3></center>";

?>   

 

    My database name = kime

    2 table that are branch_login

    ID = BIGINT

    Branch_Codename=varchar

    Branch_Name=varchar

    Branch_Password=varchar

    Userlevel - int

  

 

 

counter_cash  table as the picture below where check by is varchar 255

 

 

 

 

In branch_login table  I had 3 branch_code name that are (Paul,Rick,Jackson) and their Userlevel were 0 that is admin

 

After admin starting to select location at countercashadminselect.php and submit it, the page moves to countercashadminview.php in which there is Check_By field that was checked by admin(See the picture below)

 

59831484982375430597.jpg My main question was if another admin login and want to view data, the data must be check by him because I was stucked where I mistakenly put this command

 $sql = mysql_query("UPDATE counter_cash SET Check_By = '$b'");  from counteradminselect.php as it update and insert check by same name person  but what I want was the moment admin choose location the check by field is being checked by the name of admin who logging at that time for example if another data being inserted by user, the other admin came and it update the check by field

 

Sorry if again I making confusion :(

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.