Nov 22, 2009

Showing A Users Ip Address In Php

free web hosting
Open Discussion > MODERATED AREA > Tutorials

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.

Comment/Reply (w/o sign-up)

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

Comment/Reply (w/o sign-up)

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

Comment/Reply (w/o sign-up)

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

Comment/Reply (w/o sign-up)

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

Comment/Reply (w/o sign-up)

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

Comment/Reply (w/o sign-up)



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*

This textarea will convert to Rich-Text automatically (IE, Firefox, Chrome)

Similar Topics

Keywords : showing, users, ip, address, php

  1. Deny Or Grant Users Access To Files Of Choice (vista)
    Uses Bat Files To Deny Or Grant People Access To Files (3)
  2. Sharepoint Calendars Integrated Into Outlook 2007
    Showing multiple Sharepoint Calendars in Outlook 2007 (Company wide De (0)
    Reason you would need to use this: If you have Multiple Sharepoint Calendars that you need to see
    side by side with your personal calendar in Outlook 2007. This tutorial is for company wide
    deployment. Requirements: Outlook 2007, Sharepoint 3.0 or Sharepoint 2007, Active Directory (To
    control using Group policies). Other: Will work with Outlook 2003 but will not update changes back
    to Sharepoint Calendar (Only one way: Sharepoint to Outlook 2003) 1) Create the Calendars Create
    as many Calendars as you need on your Sharepoint site (this could be on diferent sites or....
  3. How To Disable Firefox's Awesome Bar
    restore old location/address bar from firefox 2 (7)
    How To Disable Firefox's Awesome Bar Many people are struggling to find the benefits of
    the so-called Awesome Bar as one member so truthfully pointed out , the smart tag makes your
    viewing "illicit" sites more obvious, particularly when people are peering over as you're typing
    keywords in /tongue.gif" style="vertical-align:middle" emoid=":P" border="0" alt="tongue.gif" />
    Anyway, for those of us who are too lazy to clear their history at the appropriate times, there are
    two steps to disabling its function entirely: Type about:config into the locat....
  4. 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....
  5. Verifying Your Email Address
    A Simple PHP Tutorial. (1)
    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) ....
  6. Opening Nat On Your Xbox - Upnp With Netgear
    for NETGEAR users with UPnP enabled (1)
    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....
  7. Encode Your Email Address
    Confuse the Spam Bots, but not your viewing clients (5)
    Spam bots often 'scrape' pages to glean information and collect email addresses. I don't
    like that. To combat the Bots from collecting my address off of my site, I wrote a script that
    includes 'obscures' the address in several ways. It adds 'AT' where the '@'
    sign is and then replaces the '.' with 'DOT' so it is humanly readable, but not by
    the Bots. Also, it encodes the 'mailto' and the address used in the 'mailto' so it
    shows okay on the web page and on:hover, but it is actually encode into hex value....
  8. 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 ....
  9. 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....
  10. Asking Users To Confirm If They Wish To Leave The Page
    (10)
    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 ....
  11. 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); } ....
  12. 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....
  13. 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....
  14. 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....

    1. Looking for showing, users, ip, address, php

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


Showing A Users Ip Address In Php

Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com