473,398 Members | 2,380 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,398 software developers and data experts.

restrict user access on certain pages

77
Hi PPL,

On my website i have setup user log in. once they log in i want to restrict certain users from certain pages.. and on some pages i want the user to enter their username and password again..but i am stuck on how to restrict them.. any user guides on how to tackle this issue..i am using dreamweaver cs3

many thanx
Jun 30 '08 #1
1 2879
I had this problem. I got over it by using 2 sessions (User and Admin). Each page that contains the session at the top checks to see what type of session the user is in and either allows, or header redirects to the index.

Another way could be to have a separate section. for example

yourdomain.com

and
yourdomain.com/admin

The admin index would be exactly the same, just rename the sessions. You can also use sql statements in the session code too, meaning you could add a column in your user table to include access rights maybe?

Heres an example of what i have used

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. session_start();
  3. include "conn.inc.php";
  4.  
  5. if (isset($_POST['submit'])) {
  6.   $query = "SELECT username, password FROM user_info " .
  7.            "WHERE username = '" . $_POST['username'] . "' " .
  8.            "AND password = (PASSWORD('" . $_POST['password'] . "'))";
  9.   $result = mysql_query($query) 
  10.     or die(mysql_error());
  11.  
  12.   if (mysql_num_rows($result) == 1) {
  13.     $_SESSION['user_logged'] = $_POST['username'];
  14.     $_SESSION['user_password'] = $_POST['password'];
  15.     header ("Refresh: 5; URL=" . $_POST['redirect'] . "");
  16.     echo "You are being redirected to your original page request!<br>";
  17.     echo "(If your browser doesn't support this, " .
  18.          "<a href=\"" . $_POST['redirect']. "\">click here</a>)";
  19.   } else {
  20. ?>
  21.  
  22.  
Jun 30 '08 #2

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

Similar topics

3
by: Paul | last post by:
Hi all, at present I I've built a website which can be updated by admin and users. My problem, I've combined "log in" and "access levels" to restrict access to certain pages, using the built...
2
by: Jaydeep | last post by:
Hi, I want to restrict any user if he types url directly in the browser without logging to my site. Like for example user should not see any listing page of my web site by typing url...
1
by: Dave | last post by:
We have an intranet application that is under Integrated security. So in theory, anyone who has an Active Directory account in the company can access my app. So, to allow only certain users, I...
5
by: toddles666 | last post by:
Hi- Is there any way of restricting access to a database by application & account? For example, I only want the application APP1 to access the database using the USER1 account. I've tried to...
11
by: pemo | last post by:
If you were to compile/run the code below, and get the result '30', I'd be very interested to know what compiler you're using - and its optimisation settings #include <stdio.h> int test(int...
2
by: Frederick Gotham | last post by:
I'm going to be using an acronym a lot in this post: IINM = If I'm not mistaken Let's say we've got translation units which are going to be compiled to object files, and that these object...
0
by: kanu | last post by:
Hi, We have moved our domain controllers from win2K to win3K. The script below doesnt work at all now because by default Win3K disables "Network access: Let Everyone permissions apply to anonymous...
2
by: phpnoob | last post by:
I have a php script that processes a form and then posts the user input to a data file on the server in a comma delimited format. For simplicity call the file "data.csv." The script is working...
4
by: vinpkl | last post by:
hi i am working on admin section which has a login page with login id and pasword form. in my admin section i have many pages say like manage_products.php, description.php, user.php etc. if i...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.