PDA

View Full Version : Inserting IP into DB from HTML form


Trainacomin
6-25-04, 12:49 PM
Hi,

This forum has been a great help in the past and I'm it will be here as well. I've tried several different ways to get my users remote IP address to post to the DB after they fill ou a 10 question form. I can get the remote IP to show on an echo but I can't get it to insert into a column on the database. Is there something special I need to do to the database to get it to take an IP? I currently have it set for VARCHAR(50) NOT NULL.

Thanks!
Clint

devinemke
6-25-04, 12:57 PM
post your INSERT sql

Trainacomin
6-25-04, 01:03 PM
I have used several things but this is the last one.

$query = "INSERT INTO poll (song1,song2,song3,song4,song5,song6,song7,song8,s ong9,song10,ip) VALUES ('$song1', '$song2', '$song3','$song4', '$song5', '$song6', '$song7', '$song8', '$song9', '$song10', '$_SERVER['REMOTE_ADDR']')";

devinemke
6-25-04, 01:08 PM
your quotes are screwing it up, see change below:
$query = "INSERT INTO poll (song1,song2,song3,song4,song5,song6,song7,song8,s ong9,song10,ip) VALUES ('$song1', '$song2', '$song3','$song4', '$song5', '$song6', '$song7', '$song8', '$song9', '$song10', '$_SERVER[REMOTE_ADDR]')";

Trainacomin
6-25-04, 01:16 PM
That didn't work either.
Does it make a difference that I added the ip column after the table had data? So some of the rows do not have ip's?

C

Trainacomin
6-25-04, 01:35 PM
Thanks for the help in my syntax. I just figured out the problem. I was posting the form to the wrong script so it wasn't adding the IP addy.
Thanks for the help!!!

Clint