How to save user ip when posting a php form?

  • Thread starter Thread starter ekolipik
  • Start date Start date
E

ekolipik

Guest
I'm using a php photo upload script but I want to save the user ip when uploading the photo..I could not do it.. can someone help me about t

here is the code which is posting the title and extra info of the photo inserted in the form

if ($uploader->fetchMedia($file)) {

if (!$uploader->upload()) {
echo $uploader->getErrors();
} else {
$extra = isset($_POST['photo_extra']) ? $_POST['photo_extra'] : "";
$photoStatus = $photoHandler->addLocalPhoto($catId,$uploader->getSavedFileName(),$_POST['photo_title']);
$ip = $_SERVER['REMOTE_ADDR']


I'm getting user ip with this code $ip = $_SERVER['REMOTE_ADDR'];
but dont konw how to wrte it to the db
I have created a field called IP in the same table as photo_extra and photo_title
 
You need to pass that variable into a INSERT command.

http://www.w3schools.com/PHP/php_mysql_insert.asp
 
Back
Top