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

how to limit the user access to the page

how to make a user management in php, i mean that i want to limit the user
access to my page. the script will not allow 2 user have an access to my
page at the same time. the script only allow 1 user to access the page.
the second user will have the queue massage. please help me ... :)

thank's before
indra

Jul 17 '05 #1
7 2710
indie wrote:
how to make a user management in php, i mean that i want to limit the user
access to my page. the script will not allow 2 user have an access to my
page at the same time. the script only allow 1 user to access the page.
the second user will have the queue massage. please help me ... :)

thank's before
indra

Sounds like a disaster waiting to happen. This sort of question tells me
you do not really grasped the concepts of what a web page/server really
is and how they actually work... Each "page" access is autonomous. In
other words, one does not, cannot know about the other because most
webservers are multi-threaded and can also have multiple servers
responding to multiple request concurrently. This would be like trying
to control the number of water molecules dripping from your faucet.

Now, if you can explain a bit more about what you are trying to achieve,
someone here may have already "been there/done that" and can give you
some pointers.
Two things I can think of would be to modify your server to only accept
one connection at time (in which case user 2-n will go elsewhere) or
check to see if a filename exists (like pagelock.txt - no data needs be
stored in it, merely does it exist) within a particular directory and if
not create it and if it does loop until it disappears, process work,
then delete the file. However, what happens if two people try to create
a file at the same time... who wins - because the other user also thinks
he created the file unless there are boatloads of status messages as to
the success or failure of the call to create the file, keeping in mind
that Unix and Windows will allow to "overwrite" an existing file. So
both processes will think they have created it and continue on. You can
really never say that this scenario can't happen, but in the real world,
it not only can happen, but probably will -- and how will that affect
your processing?

You need to reconsider the design rather than the "fix" for your little
problem.

Michael Austin.
Jul 17 '05 #2
indie wrote:
how to make a user management in php, i mean that i want to limit the user
access to my page. the script will not allow 2 user have an access to my
page at the same time. the script only allow 1 user to access the page.
the second user will have the queue massage. please help me ... :)


Not exactly something easily done through the web. I have a couple ideas
that may work, but you'd be better off doing this through some kind of
Java applet. Anything that doesn't talk to both the server and client
machines in real time will pose quite a few problems with timeouts and
page locks.

--
Justin Koivisto - sp**@koivi.com
PHP POSTERS: Please use comp.lang.php for PHP related questions,
alt.php* groups are not recommended.
Jul 17 '05 #3
Hi Indie, Hi Micheal,

Interesting puzzle.

Michael Austin wrote:
keeping in mind
that Unix and Windows will allow to "overwrite" an existing file.


I guess Unix won't do that if the file is still open for writing.

Now if the first process first tries to open file 1 for writing and
keeps it open, then checks for file 2 to exist. If it does not, it it
creates it. Then closes file 1.

If a second process tries to do the same at aprrox. the same time, it
should either get an error for file 1 to be open for writing by an other
process, or it should find file 2 to exist.

But maybe this is overkill, it's like two phase commit, that is used for
distibuted transactions. Maybe your data is in a single database. If you
use a database that supports transactions, you should be able to SELECT
the page's record FOR UPDATE and set a boolean in its 'locked' column
and COMMIT WORK without have to worry about another process trying to do
the same at approx the same time. Newer MySQL for example versions
support this if you use the right type of table. You may have to set a
transaction isolation level to the database or table. OK, this may after
all be more complicated then those files, but OTOH, you may learn a
thing or two about transaction isolation, commit and rollback.

Greetings,

Henk Verhoeven,
www.phpPeanuts.org.

P.S. There can be a similar problem with the back key of the browser,
caching and proxies. It may prove impossible to make sure the page is
not reshown from a cache. And are you sure the form can not sucessfully
be resubmitted after an other user has established a lock?

Jul 17 '05 #4
actually i made teleoperation system that controlling my servo motor from
remote area. ofcourse only 1 user have an access for that, and the second
user can't will not have it.if both of them have an access at the same
time, my motor will "confuse" and can't move properly.

Jul 17 '05 #5
Nel
"indie" <in***@plaza.net> wrote in message
news:a5******************************@localhost.ta lkaboutprogramming.com...
actually i made teleoperation system that controlling my servo motor from
remote area. ofcourse only 1 user have an access for that, and the second
user can't will not have it.if both of them have an access at the same
time, my motor will "confuse" and can't move properly.


Give each on-line user a UID and store them in a table.

(Table structure: id, userid, incontrol, updated)

Each time the page loads check "incontrol". If all set to FALSE then output
a button on the control page to allow a user to take control.
Check when posted that all "incontrol" are all still set to FALSE, then set
the active user to incontrol = TRUE.

If current user is incontrol then output a button to allow the user to
relinquish control (incontrol = FALSE)

"updated" as a timestamp will allow you to delete any users that are
inactive for a while, (stops someone taking control indefinitely).

That's about it.
Nel.
Jul 17 '05 #6
"Nel" <ne***@ne14.co.NOSPAMuk> wrote in message news:<40***********************@ptn-nntp-reader04.plus.net>...
"indie" <in***@plaza.net> wrote in message
news:a5******************************@localhost.ta lkaboutprogramming.com...
actually i made teleoperation system that controlling my servo motor from
remote area. ofcourse only 1 user have an access for that, and the second
user can't will not have it.if both of them have an access at the same
time, my motor will "confuse" and can't move properly.


Give each on-line user a UID and store them in a table.

(Table structure: id, userid, incontrol, updated)

Each time the page loads check "incontrol". If all set to FALSE then output
a button on the control page to allow a user to take control.
Check when posted that all "incontrol" are all still set to FALSE, then set
the active user to incontrol = TRUE.

If current user is incontrol then output a button to allow the user to
relinquish control (incontrol = FALSE)

"updated" as a timestamp will allow you to delete any users that are
inactive for a while, (stops someone taking control indefinitely).

That's about it.
Nel.


Nel,
You explained it, but from the original post I am NOT sure they can
understand what is needed. Truth be told, I don't think the original
user is even checking this site to see if their question is being
answered...

BUT if they are...
The way I would try to explain it is like this.

You need a permanent db/file-based option for what you want.
You need someway for THAT page to check to see if someone else has it
opened.
Every time that page opens, it should check.
"Am I already opened?
If I am already opened, then don't open for this new guy.
If I am NOT opened, then open and note in the db/file that I am now
opened.
If I am already opened? I should also check:
How long have I been opened?
If I have been opened longer than allowed, then note in the db/file
and close.
If I have been opened less than I am allowed, stay opened."

THAT should cover it...
I think...

I just recently started work on a personal CMS.
The User Authentication is the hardest part.
How do you register users as still signed in?
Difficult, but not impossible.
I finished my user authentication and am now working on HTML
generation!
Yeah!
Jul 17 '05 #7
thank's guys

Jul 17 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: Mike A | last post by:
Hi, I'm hoping someone can help me with this. I have a URL for which I'd like to limit access to by time. For example,say I have a URL that I don't want accessable on Monday mornings between...
12
by: Ann D. | last post by:
Hi! I'm creating a website that has a few pages... question is, how can I prevent a user from going directly to a page. i.e. user has to go through myPage1.asp (page takes some user info) to...
5
by: Mitchell Thomas | last post by:
I am using Oracle as a backend and have a field set as Varchar2(2000). The problem i have is access interprets this as a memo field and allows the user to type more than 2000 characters but does...
6
by: Hannu | last post by:
Hi. In the ldb file you can see the users of the mdb-file. If you open the mdb-file your machine and username will be written in the lbd- file. Allthough you close the mdb-file your name won't...
5
by: Nosferatum | last post by:
I am in need of a solution on how to solve this problem: I need to limit access to six different folders. My users are validated in a system which check their prescence with a couple of...
2
by: Bob | last post by:
Hi all, My databases seem to become corrupted as soon as they reach 2GB. Once it does become corrupted the only fix is to create a new database and transfer everything into that. I need to...
6
by: Nosferatum | last post by:
Hi, on my Apache server I want to limit access to a certain file ouput (from php/MySQL) to just one IP. The idea is that users from another site should click a link whic redirects them to my...
10
by: Drew | last post by:
I am trying to limit access to certain pages on our intranet, and have been using the following code to do so, dim Login, L, LL, StringLen, NTUser Set Login =...
4
dlite922
by: dlite922 | last post by:
hey guys, I'm doing some brain storming and getting ideas to come up with a solution. I have a list of ....data... that is displayed 10 per page with the LIMIT clause. Simply put: My...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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...
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...
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: 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
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.