Jump to content

help me on multiple users login..


dd

Recommended Posts

can someone outhere help me on how to login multiple users in one page..?? :(  here is my coding...please feel free to give any comment...tq..

 

<?php

  include('connection.php');

  if (isset($_POST['login']))

  {

  $noid=$_POST['noid'];

  $password=$_POST['password'];

  $_SESSION['noid']=$noid;

  $_SESSION['password']=$password;

 

  $result=mysql_query("select * from login where noid='$noid'");

  if(mysql_num_rows($result)>0)

{

$row=mysql_fetch_array($result);

if($password==$row["password"] and $user==$row["pelajar"])

{

header("Location:utamapel.php");

ob_end_clean();

}

 

elseif($password==$row["password"] and $user==$row["penyelia"])

{

header("Location:utamapens.php");

ob_end_clean();

}

 

elseif($password==$row["password"] and $user==$row["pentadbir"])

{

header("Location:utamapent.php");

ob_end_clean();

}

 

else

{

echo "<center><font face='Arial' color='red' size='2'>SORRY, invalid id and password";

}

}

else

{

echo "<center><font face='Arial' color='red' size='2'>SORRY, invalid id and password";

}

}

?>

Link to comment
https://forums.phpfreaks.com/topic/130249-help-me-on-multiple-users-login/
Share on other sites

my problem is,when user log in to my system,the page will direct only into the 1st location(utamapel.php) below.even if i'm log in using different id(penyelia),the page still go to the 1st location,but the id still remains as they logged.

so i'm confuse why it still direct to the 1st location even i log in as a penyelia.

sorry for any misunderstanding,i'm new here.

 

<?php
        include('connection.php');
        if (isset($_POST['login']))
        {
        $noid=$_POST['noid'];
        $password=$_POST['password'];
        $_SESSION['noid']=$noid;
        $_SESSION['password']=$password;
       
        $result=mysql_query("select * from login where noid='$noid'");
           if(mysql_num_rows($result)>0)
         {
            $row=mysql_fetch_array($result);
            if($password==$row["password"] and $user==$row["pelajar"])
            {
               header("Location:utamapel.php");
               ob_end_clean();
            }
            
            elseif($password==$row["password"] and $user==$row["penyelia"])
            {
               header("Location:utamapens.php");
               ob_end_clean();
            }
            
            elseif($password==$row["password"] and $user==$row["pentadbir"])
            {
               header("Location:utamapent.php");
               ob_end_clean();
            }
            
            else
            {
               echo "<center><font face='Arial' color='red' size='2'>SORRY, invalid id and password";
            }
         }
         else
         {
            echo "<center><font face='Arial' color='red' size='2'>SORRY, invalid id and password";
         }
      }
      ?>

pelajar,penyelia and pentadbir is in the same field.which is mean:

 

noid | password | user

 

123      | 123456  | pelajar

456      | 789123  | penyelia

789      | 456789  | pentadbir

 

this is an example of my login table in my database.user is the fieldname of this 3 users..

i cn't get u...hw 2 declare user in login form..

coz i only login using id and password..

 

 $noid=$_POST['noid'];
        $password=$_POST['password'];
        $_SESSION['noid']=$noid;
        $_SESSION['password']=$password;

 

i'm new in php..hope u don't mind with my silly question sometimes.. :(:-[

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.