Jul 9, 2008

Showing A Users Ip Address In Php

Free Web Hosting, No Ads > CONTRIBUTE > Tutorials

free web hosting

Showing A Users Ip Address In Php

yoofus
In this simple tutorial I will explain how to show a users IP address in your website statistics.

Open the file you would like to show the IP in, and insert this code where you want it to show:

CODE

<?php echo $_SERVER["REMOTE_ADDR"]; ?>


An IP Address whould show up. If you would like to have text infront of the IP, for example, IP Address: Blah Blah. Type:

CODE

IP Address: <?php echo $_SERVER["REMOTE_ADDR"]; ?>


Make sure to save the file as '.php' format, otherwise the code will not work.

Reply

maddog39
Well thats nice and easy for the n00bs, lol. However an alot better cleaner way of doing it is like this...
[CODE]
<?php
$ip = getenv('REMOTE_ADDR');
echo "<p>IP: $ip</p>";
?>
then with that way you can also do thing like HTTP_USER_AGENT or HTTP_GET_VARS all in one variable/function. Make sense? wink.gif biggrin.gif

Reply

yoofus
I know maddog, but this tutorial was for beginners!

Reply

maddog39
I know. However there is still an even easier way of doing it than that. Just go...
CODE

<?php echo "IP: $REMOTE_ADDR"; ?>

Thats even shorter. wink.gif biggrin.gif

Reply

yoofus
Thanks, I didn't know about that way. You get a reputation point for helping me smile.gif

Reply

maddog39
No problem, your always welcome as everyone is. smile.gif Thanks for the rep point too. wink.gif biggrin.gif

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Recent Queries:-
  1. show ip-address php code - 11.62 hr back.
  2. php user ip display text - 14.74 hr back.
  3. php user ip address - 20.42 hr back.
  4. php user ip address - 15.16 hr back.
  5. php echo user ip - 25.66 hr back.
  6. php get user ip address - 19.18 hr back.
  7. php get ip address of user - 7.60 hr back.
Similar Topics

Keywords : showing users ip address php

  1. How To Disable Firefox's Awesome Bar - restore old location/address bar from firefox 2 (4)
  2. How To Control Other Users’ Privileges (microsoft Windows Steadystate 2.5) - (1)
    Recently Microsoft has developed a program that makes user control easier. The program is called
    Windows SteadyState 2.5 and it needs a genuine version of windows. System Requirements
    • Supported Operating Systems: Windows Vista Enterprise; Windows Vista Home Premium; Windows
    Vista Ultimate Windows XP Professional, Windows XP Home Edition, Windows XP Tablet PC Edition with
    Windows XP Service Pack 2 (SP2) installed or Service Pack 3 (SP3) installed, Windows Vista Business,
    Windows Vista Home Basic, Windows Vista Starter, or Windows Vista with Servi...
  3. Verifying Your Email Address - A Simple PHP Tutorial. (0)
    Hi, everyone. I'm offering the next PHP tutorial that verifies an email address of an user who
    wants to register on your site. This is how it works. When someone, went to registration page and
    filled out all of the details such as Name, Password, email and so on and submit those details to a
    server. The user is getting unique registration code to his or her email account, the one has to be
    clicked to activate the account. 1. Outline: a) You need to create or build the following files:
    -config.php (The configuration file) -signup.php (Initial Registration) ...
  4. Opening Nat On Your Xbox - Upnp With Netgear - for NETGEAR users with UPnP enabled (0)
    I think all of the NETGEAR Routers now come with UPnP Follow this tutorial and i will show you how
    to open your NAT. 1. Go to 192.168.1.1 (or 192.168.0.1 - or whatever they supplied you with) 2. Go
    down to maintenance and 'Attached Devices'. 3. My xbox is named '---' - most xboxes
    have that default name. 4. Make sure your xbox is located there and is in the IP you selected in
    your xbox wifi setup. 5. Now go down to 'Advanced' then 'UPnP' 6. If the
    'Turn UPnP On' is toggled - then uncheck it and apply. Then when it update...
  5. Dynamic Signature - Yet Another Way To Do It - Create dynamic sigs for multiple users using .htaccess and RewriteRule (0)
    Ever since I connected a program I made in Visual Basic to MySQL database, I had an idea to create
    some sort of a status page... And I did that, where I updated my connection status every 60 seconds,
    updated my Winamp playlist, and several other interesting things... Then, I figured I could create
    an image, and display all that info, and show it on forums, as a signature... And I made a great
    PHP script, that look real fancy, and does the job perfectly... So, I was adding the reference to
    http://status.galahad.trap17.com/stat.php to all the forums... BUT (there's ...
  6. How To: Have Opera Check C-panel Webmail - Geared toward Trap17 users (1)
    This tutorial is valid for Opera 9 or above; but previous versions might work. In the menu bar,
    go to Tools > Mail and chat accounts... Click on Add... Make sure Regular e-mail
    (POP) is selected. (It should be by default.) Click Next > . In this section, you see three
    fields: Real Name , E-mail address , and Organization . Organization is
    optional. Type in your name in the Real Name field, and your account's e-mail in the
    E-mail address field (syntax: cpanel_username@your_subdomain.trap17.com). Click Next...
  7. Asking Users To Confirm If They Wish To Leave The Page - (5)
    I am sure all of us have had the frustration of having to retype an entire email from scratch
    because we accidentally hit "back" or otherwise left the page. As web technology improves and
    becomes more profound, such problems have found their simple solutions, as displayed by Google on
    Gmail, Google Calendars, Google Pages, Blogger etc. This tutorial will explore this script used to
    prevent a user from leaving the page accidentally. In order to achieve this, make sure your users
    have Javascript enabled. We will be using window.onbeforeunload. Firstly, open up your HTML ...
  8. Building An Address Book With Java - (1)
    Dear Friends I am sharing a java program with all of u which I built a few years back. I guess it
    will help beginners. It uses java utill package to store data in a flat file. The File
    Name-----phone.java import java .io .*; import java .util .*; import java.awt.event.*; public
    class phone { public void new_record() { String id,name,city,add,number,total,list;
    boolean bln=false; try { Properties pr=new Properties(); FileInputStream
    fin=new FileInputStream("phone.dat"); if(fin!=null) { pr.load(fin); }...
  9. Configuring Dns Settings For Website - Nameserver, A-Address, DNS configuration (1)
    Most of the people have problems configuring their website. After registering their domain, many get
    confused in configuring their domain (basically the DNS settings). This small tutorial will help you
    get started with DNS settings configuration. A domain can be basically pointed to a server using 2
    main techniques. 1. Nameserver (the most recommended way) 2. A Address (Not recommended)
    Configuring using Nameservers ==================== Login to your domain Control panel provided by
    your DOMAIN NAME PROVIDER / REGISTRAR. Not your webhost. Search for settings like DN...
  10. Who's Viewing My Site? - Targeted for AIM users (11)
    As some of you may know, I asked a question on how to get a portion of the URL in the address bar
    and save it, and thanks to several sources*, I have successfully learned how to do that. Today, I
    will share with you, step-by-step, my knowledge. The object of this tutorial is to mimic a
    feature on many subprofiles where you're able to see the AIM screennames of people who viewed
    your site. Note : The URL that I will be using extensively throughout this tutorial is
    http://yoursite.trap17.com . This is not a special URL reserved on trap17 but is merely a represe...
  11. Excluding Your Site From Showing Up On Search Engines - Or how to prevent stalkers from finding your personal site. (0)
    Firstly, I suppose there are very few people here who would want to do this. Most people want
    their sites to be listed on search engines, and these are probably the ones thinking that I must
    have a loose screw or something. But if you use your site for personal blogging and want to keep it
    open to friends and yet prevent your privacy from being infringed upon, this is worth looking at.
    What you need: 1. A text editor. Notepad works fine for me. 2. Coffee. (Not because you're going
    to stay up all night, but because I like to drink coffee for any and every reason po...



Looking for showing, users, ip, address, php

Searching Video's for showing, users, ip, address, php
advertisement



Showing A Users Ip Address In Php



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE