how to admin and user to login in the same interface but after login admin will go to page register staff. while the user will go to search page staff who have been on the list by admin. what are the steps that need to be placed and coding for this situation ? please help me :(

do you have a distinction in your database for admin?

It depends on how you divide normal users from admin users in your DB. If for example you divide them let's say with a "level" value and admin is set to 0 and normal user to 1 the thing becomes quite simple! After checking the user credentials you can retrive the user level and if the level returns "0" you redirect to the admin interface and if the user level is "1" you send the user to the normal user interface.

Paste your code here noone can help you this way.You have to do some thing yourself and then others can help you out.

u just have to put condition on loginform and u can redirect ur pages to admin and user

<?php
session_start();
include("connection.php");
?>
<?php
$count="";
if(isset($_POST['sub']))
{
   if($_POST['txt_user']=="")
   {
      ?>
      <script>alert("please enter user name");</script>
      <?php
      $count++;
   }
   if($_POST['txt_pass']=="")
   {
   ?>
   <script>alert("please enter password");</script>
   <?php
   $count++;
   }
   }
?>
<?php
if(isset($_POST['sub']) && $count==0)
{
    $f_name=$_POST['txt_user'];
    $password=$_POST['txt_pass'];

  $select="select * from log_in where username='".$f_name."' and password='".$password."'";
  $query=mysql_query($select);
  $row=mysql_fetch_array($query);
  if($row['username']==$_POST['txt_user'] && $row['password']==$_POST['txt_pass'])
  {
    $_SESSION['f_name']=$row['username'];
    ?>
    <script>window.location="book.php";</script>
    <?php
  }
   else
     {
  ?>
  <script>alert("Username or Password Invalid");</script>
  <?php
     }
 }
?>

<form method="post">
  <table>
     <tr>
        <td colspan="2" align="center">Log In</td>
     </tr>
     <tr>
        <td>Username</td>
        <td><input type="text" name="txt_user"  ></td>
     </tr>
     <tr>
        <td>Password</td>
        <td><input type="password" name="txt_pass" ></td>
     </tr>
     <tr>
         <td colspan="2" align="center"><input type="submit" name="sub" value="Log in"></td>
     </tr>

  </table>
</form>

just put ur query at at 'else' statement to fetch user table data than u can login to user and admin which u want

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.