954,561 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

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

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? :S

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! :*

LiBOC
Junior Poster in Training
73 posts since Jul 2005
Reputation Points: 10
Solved Threads: 1
 

Well, if you put your routers into a mysql table, then once selected you could flag a column (as being in use).

pritaeas
Posting Expert
Moderator
5,480 posts since Jul 2006
Reputation Points: 653
Solved Threads: 875
 

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.

lordspace
Junior Poster in Training
90 posts since May 2006
Reputation Points: 18
Solved Threads: 6
 

I will try that... thanks so much, even for replying!

LiBOC
Junior Poster in Training
73 posts since Jul 2005
Reputation Points: 10
Solved Threads: 1
 

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

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.

LiBOC
Junior Poster in Training
73 posts since Jul 2005
Reputation Points: 10
Solved Threads: 1
 

use file_exists function

$filename = '/path/to/foo.txt';

if (file_exists($filename)) {
    echo "The file $filename exists";
} else {
    echo "The file $filename does not exist";
}
ryan_vietnow
Posting Pro
578 posts since Aug 2007
Reputation Points: 28
Solved Threads: 71
 

Oh Hi,

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

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.

LiBOC
Junior Poster in Training
73 posts since Jul 2005
Reputation Points: 10
Solved Threads: 1
 

Hey hi!

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

Dav

use file_exists function

$filename = '/path/to/foo.txt';

if (file_exists($filename)) {
    echo "The file $filename exists";
} else {
    echo "The file $filename does not exist";
}
LiBOC
Junior Poster in Training
73 posts since Jul 2005
Reputation Points: 10
Solved Threads: 1
 

I think that's not possible,Use javascript instead for popup boxes

ryan_vietnow
Posting Pro
578 posts since Aug 2007
Reputation Points: 28
Solved Threads: 71
 

something like:

echo '<script type="text/javascript">
            alert("hello");
         </script>';


but this is not recommended..

ryan_vietnow
Posting Pro
578 posts since Aug 2007
Reputation Points: 28
Solved Threads: 71
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You