用php获取客户端IP地址的方法,具体代码如下:
echo $_POST['name'].'
';
echo $_POST['sex'].'
';
echo $_POST['email'].'
';
echo
$_POST['info'].'
';
$ip=$_SERVER["REMOTE_ADDR"];
//------基本设定--------
$mysql_server_name="localhost";
$mysql_username
="root";
$mysql_password ="123456";
$mysql_database
="liuyanban";
//----------
//准备好你的sql语法(新建)
$sql="INSERT INTO
`gbook` (`id` ,`name` ,`sex` ,`email` ,`info` ,`ip` ,`time_at` )VALUES ('',
'".$_POST['name']."', '".$_POST['sex']."', '".$_POST['email']."',
'".$_POST['info']."', '".$ip."', NOW( ) )";
$conn=mysql_connect($mysql_server_name,$mysql_username,$mysql_password);
mysql_select_db($mysql_database,$conn);
$result=mysql_query($sql);
$id=mysql_insert_id();
mysql_close($conn);
?>
///