943,832 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 1388
  • PHP RSS
Jul 28th, 2008
0

Allowing one user at a time to access a particular PHP Page

Expand Post »
Dear Forum,

Thanks for taking time reading this post.

I checked out on sessions and cookies but I guess they are more towards the client side?

Is there a way to achieve this:

The PHP program I am doing is to reverse Telnet (Terminal Server and it accessing through CONSOLE port) into a router from a selection of a dropdown list box. Once this user had successfully logged into the router, other users(different computer) will NOT be able to even see this same logged on router as a selection to log in again.

I hope you can understand my question.

Thanks alot people!
Similar Threads
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
LiBOC is offline Offline
73 posts
since Jul 2005
Jul 29th, 2008
0

Re: Allowing one user at a time to access a particular PHP Page

Well, if you put your routers into a mysql table, then once selected you could flag a column (as being in use).
Sponsor
Featured Poster
Reputation Points: 550
Solved Threads: 729
Bite my shiny metal ass!
pritaeas is offline Offline
4,176 posts
since Jul 2006
Jul 29th, 2008
1

Re: Allowing one user at a time to access a particular PHP Page

One solution could be:

create a temp file called lock.txt.
The file will be created only after a successful login. The file will be deleted after logout.
Before login you check if the file exists and if it does the script stops.

Note:
if for some reason the temp file cannot be deleted. It is a good idea before login to check for last modification time if it is more than 24hours delete the file.
Reputation Points: 18
Solved Threads: 6
Junior Poster in Training
lordspace is offline Offline
90 posts
since May 2006
Aug 6th, 2008
0

Re: Allowing one user at a time to access a particular PHP Page

I will try that... thanks so much, even for replying!
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
LiBOC is offline Offline
73 posts
since Jul 2005
Aug 7th, 2008
0

Re: Allowing one user at a time to access a particular PHP Page

Hi,

I tried with the lock.txt. It worked pretty well.

But do you know the coding to check if a file exist or not? I am very new to PHP. Thanks!

Dav

Click to Expand / Collapse  Quote originally posted by lordspace ...
One solution could be:

create a temp file called lock.txt.
The file will be created only after a successful login. The file will be deleted after logout.
Before login you check if the file exists and if it does the script stops.

Note:
if for some reason the temp file cannot be deleted. It is a good idea before login to check for last modification time if it is more than 24hours delete the file.
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
LiBOC is offline Offline
73 posts
since Jul 2005
Aug 7th, 2008
0

Re: Allowing one user at a time to access a particular PHP Page

use file_exists function

php Syntax (Toggle Plain Text)
  1.  
  2. $filename = '/path/to/foo.txt';
  3.  
  4. if (file_exists($filename)) {
  5. echo "The file $filename exists";
  6. } else {
  7. echo "The file $filename does not exist";
  8. }
Reputation Points: 28
Solved Threads: 71
Posting Pro
ryan_vietnow is offline Offline
578 posts
since Aug 2007
Aug 7th, 2008
0

Re: Allowing one user at a time to access a particular PHP Page

Oh Hi,

Sorry. I done that detection of existing file already. Thanks,

Click to Expand / Collapse  Quote originally posted by lordspace ...
One solution could be:

create a temp file called lock.txt.
The file will be created only after a successful login. The file will be deleted after logout.
Before login you check if the file exists and if it does the script stops.

Note:
if for some reason the temp file cannot be deleted. It is a good idea before login to check for last modification time if it is more than 24hours delete the file.
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
LiBOC is offline Offline
73 posts
since Jul 2005
Aug 7th, 2008
0

Re: Allowing one user at a time to access a particular PHP Page

Hey hi!

Thanks for replying. Do you know how to pop u an alert window message in PHP?
Thanks,

Dav

use file_exists function

php Syntax (Toggle Plain Text)
  1.  
  2. $filename = '/path/to/foo.txt';
  3.  
  4. if (file_exists($filename)) {
  5. echo "The file $filename exists";
  6. } else {
  7. echo "The file $filename does not exist";
  8. }
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
LiBOC is offline Offline
73 posts
since Jul 2005
Aug 7th, 2008
0

Re: Allowing one user at a time to access a particular PHP Page

I think that's not possible,Use javascript instead for popup boxes
Reputation Points: 28
Solved Threads: 71
Posting Pro
ryan_vietnow is offline Offline
578 posts
since Aug 2007
Aug 7th, 2008
0

Re: Allowing one user at a time to access a particular PHP Page

something like:

php Syntax (Toggle Plain Text)
  1. echo '<script type="text/javascript">
  2. alert("hello");
  3. </script>';

but this is not recommended..
Last edited by ryan_vietnow; Aug 7th, 2008 at 2:42 am.
Reputation Points: 28
Solved Threads: 71
Posting Pro
ryan_vietnow is offline Offline
578 posts
since Aug 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: How do I add up all values of rows in a table???
Next Thread in PHP Forum Timeline: client side php scripting vs javascript





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC