|
|
|
|
Thread title: Storing an IP in a Database |
|
|
|
|
|
Thread tools
Search this thread
Display Modes
|
|
07-28-2006, 08:47 PM
|
#1
|
Status: Jakowenko.com
Join date: Jun 2005
Location: Michigan
Expertise:
Software:
Posts: 2,199
|
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?
|
|
07-28-2006, 11:26 PM
|
#2
|
Status: Member
Join date: Feb 2006
Location: Omaha, NE
Expertise:
Software:
Posts: 452
|
mysql_query("INSERT INTO ip VALUES ($ip)");
|
|
07-28-2006, 11:43 PM
|
#3
|
Status: Superstar
Join date: Apr 2005
Location:
Expertise:
Software:
Posts: 4,449
|
Yep, anything like:
Code:
<?
$ip = $_SERVER['REMOTE_ADDR'];
MYSQL_QUERY("INSERT INTO internetprotocols VALUES ($ip)");
?>
Will work.
|
|
07-29-2006, 02:59 AM
|
#4
|
Status: Junior Member
Join date: Jul 2006
Location:
Expertise:
Software:
Posts: 42
|
PHP Code:
<?
//db connection or config file
$ip = $_SERVER['REMOTE_ADDR'];
MYSQL_QUERY("INSERT INTO ip VALUES ($ip)");
?>
You will also need to set up a table called "ip"
|
|
07-29-2006, 03:12 AM
|
#5
|
Status: Request a custom title
Join date: Dec 2005
Location: Arizona
Expertise:
Software:
Posts: 5,200
|
May I point out that all your codes are exactly the same except for the name of the table? What is the point in posting the same thing twice..
|
|
07-29-2006, 08:24 AM
|
#6
|
Status: Junior Member
Join date: Jul 2006
Location:
Expertise:
Software:
Posts: 42
|
Well, the guy obv. doesnt know php that well. Fair enough he's trying to learn...we were pointing him in the right direction. Everyone has a different coding style...
|
|
07-29-2006, 03:26 PM
|
#7
|
Status: Geek
Join date: Apr 2006
Location: Denver, CO
Expertise: Software
Software: Chrome, Notepad++
Posts: 6,894
|
it should be a varchar 15
|
|
07-30-2006, 08:22 PM
|
#8
|
Status: Dediport Hosting
Join date: Jul 2006
Location: Berkshire
Expertise: programming, business
Software: Dreamweaver
Posts: 1,316
|
Also, they given you this code but are you storing just everyones ip or other information with it, if your just storing the ip is assume you are trying to count how many unique users onto your site but to stop it storing the same twice i think you should have a field called count.
|
|
07-30-2006, 08:32 PM
|
#9
|
Status: Jakowenko.com
Join date: Jun 2005
Location: Michigan
Expertise:
Software:
Posts: 2,199
|
I got it working, it was already for an exisiting site that is with other info. Thanks for the help you guys.
|
|
|
|
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
|