473,320 Members | 2,003 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.

how to direct users

Can anyone tell me how to direct unregistered users who try to acess the inner pages back to the home page along with a error message telling them to please login to view the pages in PHP
Jan 27 '07 #1
1 1063
ronverdonk
4,258 Expert 4TB
You can accompish this by registering your logged-in users in a cookie or the session array and redirecting anyone who is not registered in there. The most basic approach to this is:

- start each of your scripts with the PHP session_start() command
when the user has logged in successfully, register his name in the $_SESSION array, e.g.
[php]$_SESSION['username']=$user;[/php]
- at each page, check if the user is registered by checking the $_SESSION array, if not, redirect the user to the login script:
[php]if (!isset($_SESSION['username']))
header('Location: logon.php');
else
.. continue processing ..[/php]
A more complete and indepth tutorial on this subject can be found at The First Session.

Ronald :cool:
Jan 28 '07 #2

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

Similar topics

12
by: CJM | last post by:
I'm setting up some web-based (ASP) reports that query an Access DB. I also want certain people to be able to access and manipulate the database directly. However, if the database is open in...
22
by: Rich | last post by:
I am trying to create a site that will re-direct a user based on their OS. For this site I will need to send NT4 and 95 users to site A and 2000/XP users to site B. All others should be directed...
1
by: acrocker | last post by:
I would like to provide access to users who need to be taken directly to the relevant page without further navigation instructions. Unfortunately the page I want to access is built using a...
1
by: greg.southerland | last post by:
How would I direct users to a different page based on which radio button they select in a form? Thanks for any help you can provide. Greg
5
by: Bill Davidson | last post by:
All: Pardon the newbie question, but let's say I've got two pages in my website: Welcome.aspx NoNav.aspx I want users to be able to navigate to the welcome.aspx page (e.g....
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...
5
by: Rahul B | last post by:
Hi, I am having the following issues while trying to restrict the current user from creating any objects. Below is the privileges for the user and response when i try to create a table in that...
1
by: Chase Kang #52 | last post by:
I have a web application using custom authentication and role management, which seems to work properly. I also have a web config file with the following: <location path="systems"> <system.web>...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
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: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
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...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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...

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.