Page 1 of 1

IP address

Posted: Fri Dec 20, 2002 2:29 pm
by jamal
How can i retrive the IP address of a user connected to database without using form?
Please, help me.

Thanks

Posted: Fri Dec 20, 2002 3:12 pm
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]

Posted: Fri Dec 20, 2002 5:11 pm
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.

Posted: Sun Dec 22, 2002 12:18 am
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);

?>

Posted: Sun Dec 22, 2002 10:55 am
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.

Posted: Sun Dec 22, 2002 12:01 pm
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