IP address

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jamal
Forum Commoner
Posts: 57
Joined: Sat Oct 26, 2002 7:53 pm
Location: London

IP address

Post by jamal »

How can i retrive the IP address of a user connected to database without using form?
Please, help me.

Thanks
penguinboy
Forum Contributor
Posts: 171
Joined: Thu Nov 07, 2002 11:25 am

Post by penguinboy »

[quote]How can i retrive the IP address of a user connected to database without using form? [/quote]

how are they connecting to the database??

is it via webpage?

if so then just

$_SERVER[REMOTE_ADDR]
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post by hob_goblin »

Code: Select all

$_SERVERї'REMOTE_ADDR']
it is extremely good practice to use quotes, as you don't want the variable to be parsed as a constant.
oldtimer
Forum Contributor
Posts: 204
Joined: Sun Nov 03, 2002 8:21 pm
Location: Washington State

Post by oldtimer »

I use this in alot of things. Sometimes to put in a DB and sometimes just a text file. Other times I echo it to the screen.

Code: Select all

<?php
$lastip=($REMOTE_ADDR);

?>
jamal
Forum Commoner
Posts: 57
Joined: Sat Oct 26, 2002 7:53 pm
Location: London

Post by jamal »

can you help me on how to get localtime ??
I want to have day and time set locally on my site.
I got it wrong.
please help me.
oldtimer
Forum Contributor
Posts: 204
Joined: Sun Nov 03, 2002 8:21 pm
Location: Washington State

Post by oldtimer »

You would use the date function.

http://www.php.net/manual/en/function.date.php

Example:

Code: Select all

<?php
$time=date("l F d,  Y  h:i A T");
echo $time;

?>
Now for the moment I put this up it would be

Sunday December 22, 2002 10:03 AM PST

If you can not remember all the options just remember the function and then go to php.net or have them written down.

Jerry
Post Reply