【发布时间】:2020-08-17 08:14:48
【问题描述】:
我正在使用此代码来获取客户的信息。此代码正在运行,但它给出了一些错误。请检查我的代码,并帮助我更正它。此外:如何将用户数据存储到 MySQL 中?我enter image description here 将非常感谢你。错误如下。 注意:未定义索引:HTTP_REFERER 注意:未定义属性:stdClass::$loc in 注意:未定义属性:stdClass::$org in 注意:未定义属性:stdClass::$city in 注意:未定义属性:stdClass::$region in注意:未定义的属性:stdClass::$country 在注意:未定义的索引:HTTP_REFERER 在注意:未定义的属性:stdClass::$loc 在注意:未定义的属性:stdClass::$org 在注意:未定义的属性:stdClass::$city在注意:未定义的属性:stdClass::$region 在注意:未定义的属性:stdClass::$country 在
<?php
// This program generates a web pages that gets
// the user's information, saves it to a file,
// and displays it on the web page.
// Created by Mitchell Robinson.
// 27 July, 2014.
// Name of the ip address log.
$outputWebBug = 'iplog.csv';
// Get the ip address and info about client.
@ $details = json_decode(file_get_contents("http://ipinfo.io/{$_SERVER['REMOTE_ADDR']}/json"));
@ $hostname=gethostbyaddr($_SERVER['REMOTE_ADDR']);
// Get the query string from the URL.
$QUERY_STRING = preg_replace("%[^/a-zA-Z0-9@,_=]%", '', $_SERVER['QUERY_STRING']);
// Write the ip address and info to file.
@ $fileHandle = fopen($outputWebBug, "a");
if ($fileHandle)
{
$string ='"'.$QUERY_STRING.'","' // everything after "?" in the URL
.$_SERVER['REMOTE_ADDR'].'","' // ip address
.$hostname.'","' // hostname
.$_SERVER['HTTP_USER_AGENT'].'","' // browser and operating system
.$_SERVER['HTTP_REFERER'].'","' // where they got the link for this page
.$details->loc.'","' // latitude, longitude
.$details->org.'","' // internet service provider
.$details->city.'","' // city
.$details->region.'","' // state
.$details->country.'","' // country
.date("D dS M,Y h:i a").'"' // date
."\n"
;
$write = fputs($fileHandle, $string);
@ fclose($fileHandle);
}
$string = '<code>'
.'<p>'.$QUERY_STRING.'</p><p>IP address: '
.$_SERVER['REMOTE_ADDR'].'</p><p>Hostname: '
.$hostname.'</p><p>Browser and OS: '
.$_SERVER['HTTP_USER_AGENT'].'</p><p>'
.$_SERVER['HTTP_REFERER'].'</p><p>Coordinates: '
.$details->loc.'</p><p>ISP provider: '
.$details->org.'</p><p>City: '
.$details->city.'</p><p>State: '
.$details->region.'</p><p>Country: '
.$details->country.'</p><p>Date: '
.date("D dS M,Y h:i a").'</p></code>'
;
echo '<!DOCTYPE html><html><head><title>Who Am I?</title></head><body>';
echo $string;
echo '</body></html>';
?>
【问题讨论】:
-
但是给出了一些错误,给你什么错误?,告诉我们。
-
请粘贴错误
-
@GNassro 我已经附上了图片错误请检查..
-
我建议你删除@符号,检查是否有其他错误
-
请编辑您的问题并添加说明。不要在 cmets 中提供。
标签: php phpmyadmin