SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member Jako's Avatar
    Join Date
    Jun 2005
    Location
    Michigan
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Storing an IP in a Database

    I have this much,
    PHP Code:
    $ip $_SERVER['REMOTE_ADDR']; 
    But how do I store the IP of someone who submits a form and keep it in the database?
    Soccer Surfer | Top 10 Soccer Players

  2. #2
    SitePoint Enthusiast
    Join Date
    Sep 2005
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It really depends on how you layout your form (does it post/get to itself or another file). It's just a matter of having an insert query run after the form is submitted. I'm adding a simple query below (just add/edit the appropriate columns based on your db).

    $qry = "INSERT INTO table_name (ip,fullname,comment,datetime) VALUES ($ip, $fullname,$comment,NOW())";

    $rslt = mysql_query($qry) or die(mysql_error().$qry)

    Good luck!

  3. #3
    SitePoint Zealot geekofdaweek's Avatar
    Join Date
    May 2006
    Location
    Erie, PA, USA
    Posts
    102
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It is also best if the form's landing page collects the IP information, instead of having the IP address passed from within the form.
    John Stuttler
    Owner, Camboro Computers
    There are 10 kinds of people...
    Those who understand computers, and those who don't!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •