| | |
Show Last IP
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jun 2005
Posts: 46
Reputation:
Solved Threads: 0
hello, i am using the following code to write an ip and date to a database
[php]require_once "configgy.php";
mysql_query("INSERT INTO lastlogin(VisIP, VisDate) VALUES(\"".$HTTP_SERVER_VARS['REMOTE_ADDR']."\", NOW(),");
[/php]
I would like to call this script in another file, and everytime the script is called, have the new ip written in.
liek it is in CPANEL (log into cpanel and look at the top left, it says last log in from 127.0.0.1 or w/e your ip is)
how can i do this?
[php]require_once "configgy.php";
mysql_query("INSERT INTO lastlogin(VisIP, VisDate) VALUES(\"".$HTTP_SERVER_VARS['REMOTE_ADDR']."\", NOW(),");
[/php]
I would like to call this script in another file, and everytime the script is called, have the new ip written in.
liek it is in CPANEL (log into cpanel and look at the top left, it says last log in from 127.0.0.1 or w/e your ip is)
how can i do this?
Just include the code you have above in the script you need IPs logged for.
Make sure you create a table in the database the script has access to. Eg:
If the target script already connects to a database, and has its own database class, then you should use the target scripts database class instead of including configgy.php.
Make sure you create a table in the database the script has access to. Eg:
PHP Syntax (Toggle Plain Text)
create table if not exists 'lastlogin' ( 'id' int(11) not null auto_increment, 'VisIP' varchar(15), 'VisDate' timestamp(14) not null, primary key ('id') )
If the target script already connects to a database, and has its own database class, then you should use the target scripts database class instead of including configgy.php.
www.fijiwebdesign.com - web design and development and fun
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
•
•
Join Date: Jun 2005
Posts: 46
Reputation:
Solved Threads: 0
I have the database...
OK lemme explain this better, I have an Admin panel.
I would like to show the IP of the last person to log in.
So i would need for everytime the script was aactivated it would write the ip to the DB and clear the old one. however it would be better if it only wrote the ip on login, instead of everytime it was accessed.
OK lemme explain this better, I have an Admin panel.
I would like to show the IP of the last person to log in.
So i would need for everytime the script was aactivated it would write the ip to the DB and clear the old one. however it would be better if it only wrote the ip on login, instead of everytime it was accessed.
•
•
Join Date: Feb 2006
Posts: 32
Reputation:
Solved Threads: 1
Include that part in the code that is excuted when the user has authenticated successfully, that would ensure you only did it once per session.
You'll have to look at some mysql resources to get a better Idea with working with mysql.
What you could do is delete the entry in mysql each time you update a new entry.
Like blazing_wolf said, include the code after the user has been authenticated successfully.
If you're just writing one IP, you'd better o f just write it to a file.
Use fopen('filename.txt', 'w');
That would clear the file each write...
What you could do is delete the entry in mysql each time you update a new entry.
Like blazing_wolf said, include the code after the user has been authenticated successfully.
If you're just writing one IP, you'd better o f just write it to a file.
Use fopen('filename.txt', 'w');
That would clear the file each write...
www.fijiwebdesign.com - web design and development and fun
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
![]() |
Similar Threads
- We only give homework help to those who show effort (Computer Science)
- IE won't let site show pictures. (Web Browsers)
- the 2 little computers do not show on the taskbar, connection issue (Windows NT / 2000 / XP)
- Show Hidden Program or System Files (Windows tips 'n' tweaks)
- Show Encrypted Files in Color (Windows tips 'n' tweaks)
- Right click menu slow to show (Windows NT / 2000 / XP)
Other Threads in the PHP Forum
- Previous Thread: Help, If You Can Find My Error! Exhausted Again
- Next Thread: Please If You Can See Where My Mistake Is!
| Thread Tools | Search this Thread |
advanced apache api array beginner binary broken cakephp check checkbox class cms code cookies cron curl database date datepart display dropdownlist dynamic echo email eregi error execution file files folder form forms function functions google head href htaccess html if...loop image include includingmysecondfileinthechain insert ip javascript job joomla jquery key library limit link login mail menu mlm multiple mysql oop password paypal pdf pdfdownload php phpvotingscript problem query radio random recursion remote screen script search server sessions smarty sms sorting source space sql startup stored syntax system table traffic tutorial unicode update upload url validator variable video web youtube zend







)