laserlight wrote:Test with:
<?php echo $_SERVER['REMOTE_ADDR']; ?>
it works. i have this code:
<?
require ( "db_conn.inc.php" );
// First, check whether the add vote form was submitted
if ( $_POST['add_votes'] ) {
foreach ( $_POST as $key => $val ) {
if ( eregi ( "rating", $key ) ) {
$player_rating = explode ( "_", $val );
$sql = 'INSERT INTO rating ( player_id, draft_id, rating_value, ip ) VALUES (' . $player_rating[0] . ', "2006",' . $player_rating[1] . ',' . $ip . ')';
$add_rating_rs = $conn->Execute($sql) or die ( $conn->ErrorMsg() );
}
}
header ( "Location: results.php" );
exit;
}
$draft_rs = $conn->Execute ( "SELECT * FROM player ORDER BY player_pick ASC" ) or die ( $conn->ErrorMsg() );
$playerid = $draft_rs->Fields("player_id");
?>
I have this in the <form></form> area:
<input name="ip" type="hidden" id="ip" value="<?php echo $_SERVER['REMOTE_ADDR']; ?> ">
It isn't inserting the IP into the DB, but it is inserting the rest of the info and the IP address displays when I echo it.