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

Recommended Answers

All 11 Replies

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

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.

commented: Smart Answer... +1

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

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.

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";
}

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.

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";
}

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

something like:

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

but this is not recommended..

I WANT THAT IF A USER LOGIN BY USING ONE USER ID AND PASSWORD. That same should't be used for login from another machine. To prevent this i make a table in database which gets updated as soon as user gets login and at logout that table deletes user login information. but facing issue when user dont press logout button and turns of browser directly or system gets off suddenely due to power supply then how to prevent this..

@vishal.devgun start a new discussion for your problem

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.