【php】获取ip
2021-07-15 08:05
标签:int rem data time value log func use article addBoard.php中获取到ip 通过ajax采取POST方式发送到服务器 服务器端获取到数据,并写入数据库,即可记录ip 【php】获取ip 标签:int rem data time value log func use article 原文地址:http://www.cnblogs.com/yujihang/p/7073405.html$ip=$_SERVER[‘REMOTE_ADDR‘];
$("#submit").on("click",function(){
pcontent = $("#contain").val();
check();
ip=$("#username").attr("data-ip");
$.ajax({
url: "handle.php",
dataType: "json",
type: "POST",
data: { type:"addboard",f_name:title,f_desc:pcontent},
success:function(data){
$("#notice").html("添加成功")
console.log(data.toString());
},
error:function(data){
console.log(data);
$("#notice").html("添加失败,请稍后再试");
}
});
})
$f_ip=isset( $_POST[‘ip‘])?$_POST[‘ip‘]:"";
$sql="INSERT into t_article (f_parent_id, f_title, f_username, f_board_id,f_post_time, f_ip) values";
$sql.="(‘".$f_parent_id."‘,‘".$f_title."‘,‘".$f_username."‘,‘".$f_board_id."‘,‘".$f_post_time."‘,‘".$f_ip."‘)";
$rs1=$conn->query($sql);
$ttt=mysqli_insert_id($conn);