473,320 Members | 1,744 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Login page according to the access rights

250 100+
In my web site I want to load some menus without login and there is a admin login. When admin logged in I want to some more menus. This is my code. But it is not working. It display all menus every time. Please help me.
Expand|Select|Wrap|Line Numbers
  1. $page = $_GET['page'];
  2.  
  3. if ($page);
  4. else 
  5. $page = "index.php"; 
  6.  
  7.  
  8.     if($login=="True"){
  9.     //echo "inside admin login";
  10.         $array = array('Home'=>'index.php','Stock'=>'stock.php','Order Now'=>'orderNow.php','Contact Us'=>'contectUs.php','Add'=>'addVehicle.php','Edit'=>'editVehicle.php','Logout'=>'logout.php');
  11.  
  12.  
  13.     foreach ($array as $k=>$v){
  14.         if ($page == $v)
  15.             $background = "background='images/btn_inactive.gif' ";
  16.         else
  17.             $background = "background='images/btn_active.gif'";
  18.  
  19.         echo "<td width=200 height =35 align=center cellpadding=5 $background ><a href='$v?page=$v' class=toppanel >&nbsp;&nbsp;&nbsp;$k </a></td>";
  20.  
  21.         }
  22.  
  23.     }
  24.  
Oct 2 '09 #1
4 2535
Dormilich
8,658 Expert Mod 8TB
how do you determine whether an admin or an user is logged in?
Oct 2 '09 #2
TheServant
1,168 Expert 1GB
It looks like your line 8 that is failing if it shows all the items.
Instead of checking if login is true, which you should also check if the type is the same like this:
Expand|Select|Wrap|Line Numbers
  1. if ($login===TRUE) {
You could also check if a certain variable isset() or if a $_SESSION value (which I presume is how you know they're logged in) is set?
Oct 2 '09 #3
ghjk
250 100+
In my login page I checked whether user logged in or he is a guest.Actually my site no need to have any user login. I want to do a login part only the admin to enter data.
This is my login page and I'll get the value "true" from here.
Expand|Select|Wrap|Line Numbers
  1. if(isset($_POST['login'])){
  2.     $username=$_POST['username']; 
  3.     $password=$_POST['password'];
  4.     if((!username)||(!$password)){
  5.         $login_error = '<p class= "errormsg">Please enter all fields</p>';
  6.     }
  7.         $password_encrpt = md5(substr($password, 1, -1));
  8.         $sql = "SELECT * FROM user WHERE  Username='$username' AND Password ='$password_encrpt'"; 
  9.         $result=mysql_query($sql);
  10.         $row = mysql_fetch_array($result);
  11.         $count=mysql_num_rows($result);
  12.         if($count==1){
  13.             echo $_SESSION['Username_Ses'] =$row['Username'];
  14.             $_SESSION['login'] = "True";
  15.  
  16.  
  17.         }
  18.         else {
  19.             $ADDERROR = '<p class="errMsg" align="Center">Invalid Username or Password</p>';
  20.         }
  21.  
  22. }
  23.  
Oct 2 '09 #4
TheServant
1,168 Expert 1GB
In your original script you do not use $_SESSION['login'], you use $login, which does not exist.
Oct 4 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: George | last post by:
Hi. I've deployed a web application on a desktop computer running W2K and IIS. I'm using the desktop as a server. When I try to access the site, either from my development computer or if I...
10
by: et | last post by:
I have an asp.net program that uses a connection string, using integrated security to connect to a sql database. It runs fine on one server, but the other server gives me the error that "Login...
6
by: scottyman | last post by:
I can't make this script work properly. I've gone as far as I can with it and the rest is out of my ability. I can do some html editing but I'm lost in the Java world. The script at the bottom of...
1
by: Friends | last post by:
Hi I need to set security for row level but not based on Database user's login. It should be based on the user table login. For the particular user I need to allow only the particular records to...
1
by: Jakob Lithner | last post by:
When I started a new ASP project I was eager to use the login facilities offered in Framework 2.0/VS 2005. I wanted: - A custom principal that could hold my integer UserID from the database -...
4
by: jobs | last post by:
Hello. If my users are logged in, and try to access restricted pages I want to direct them to a custom 403 page. If they are not logged in, I would like to continue to direct them to the login...
3
by: tshad | last post by:
I am setting up a Windows Service at a clients site and a window comes up: Set Service Login that asks for UserName and Password. Is this the credentials that the service will logon as or...
2
by: =?Utf-8?B?d2R1ZGVr?= | last post by:
I have a website using windows integrated security, with anonymous access turned off. The site is used to query orders from a database and when the search takes a long time, a windows login box...
4
by: Brett | last post by:
I have an ASP.NET 2.0 application that uses Forms Authentication. The startup page contains just a login control, and the site works well on an IIS 6 web server. I am now setting the site up on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.