dd Posted October 27, 2008 Share Posted October 27, 2008 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 More sharing options...
trq Posted October 27, 2008 Share Posted October 27, 2008 A few comments. Your issue is no more urgent than anyone else's, stating it is makes people want to help less. We have tags that make code easier to read, please use them. Oh, and ps: You really haven't told us what your problem is exactly. Link to comment https://forums.phpfreaks.com/topic/130249-help-me-on-multiple-users-login/#findComment-675475 Share on other sites More sharing options...
dd Posted October 27, 2008 Author Share Posted October 27, 2008 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"; } } ?> Link to comment https://forums.phpfreaks.com/topic/130249-help-me-on-multiple-users-login/#findComment-675499 Share on other sites More sharing options...
trq Posted October 27, 2008 Share Posted October 27, 2008 Do you really have a different field for each user in your database? I would think, these $row["pelajar"] need to be $row['fieldname']. eg; Whatever the name of the filed is that stores your usernames. Link to comment https://forums.phpfreaks.com/topic/130249-help-me-on-multiple-users-login/#findComment-675542 Share on other sites More sharing options...
dd Posted October 27, 2008 Author Share Posted October 27, 2008 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.. Link to comment https://forums.phpfreaks.com/topic/130249-help-me-on-multiple-users-login/#findComment-675634 Share on other sites More sharing options...
trq Posted October 27, 2008 Share Posted October 27, 2008 Then you need to use (for example).... if($password == $row["password"] and $user == $row["user"]) Link to comment https://forums.phpfreaks.com/topic/130249-help-me-on-multiple-users-login/#findComment-675701 Share on other sites More sharing options...
dd Posted October 27, 2008 Author Share Posted October 27, 2008 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.. Link to comment https://forums.phpfreaks.com/topic/130249-help-me-on-multiple-users-login/#findComment-675738 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.