PHP Logo |
PHP-Hypertext Preprocessor.
PHP is a server side script language.Using php you can create a dynamic websites.
This is the first lesson and on this lesson you will learn how to get visitors ip and save it on your server.(i wil learn you how add this to your blog or any web sites that haven't php.)
-Display User's informations-
-Code Descriptions-
<?php -to start php file.
$ip - give a variable name to $_SERVER['REMOTE_ADDR'] (like y=mx+c).
$_SERVER['REMOTE_ADDR']-this is the code that get user ip.
gethostbyaddr($ip) -to get host name.
$_SERVER['HTTP_USER_AGENT']-get browser information.
$_SERVER['HTTP_REFERER']-get where user come from.
//-we use this to put a comment in our php file.// for 1 line comment.
/*-this is for long comment and end with */
print"what you want to display on the page";-we use this to display something on the page.
<br>-this is for line break .when we use this code.the text after this code will display in next line.
How i save user's Informations ??
-Code Descriptions-
$myfile="countip.mic"; -$myfile is the variable that for "countip.mic".
fwrite($fh,$stringData); -do that discribe on $fh variable and $stringData .(create countip.mic file and save data).
fclose($fh);-close the file that we open.
we get the date time to countip file using .date('Y-m-d H:i:s).code.
Code for Display user's information and Save(broth in one file) .
How I put this code to my website ??
First i will learn you how to add this code to your hosting that php working.
When you add this php codes to your blog or web site you must have another hosting that php working.Many hosting providers give free php working accounts.
First you must get a free hosting account.
(click here to google search about free accounts.then select one and Register on it(eg:www.000webhost.com )).
1.Create file on your desktop with .php extension (eg:countip.php) .
2.Copy the code and paste it on your file.
3.Save it and Upload it(your file) to you hosting account.
To download php zip file click here.(extract zip fle and upload it)
(To Upload Your file to your hosting account .you can use Filezilla software).
Then go to your file (after you upload it) using a browser.You can see your informations on your page.
Click here to see preview. And click here to see the save file on the server.
To get this code to your blog or website( that php not working) read this post click here.
2 comments:
You Rock!!!
Great Job!
ewrer
Post a Comment