douyuliu9527
2019-06-18 03:18
浏览 32
已采纳

使用IP和时间以PHP捕获用户名

I've written scripts to capture the IP address of a user with the time as well as to capture the username with the time but I've tried combining these and I'm having some errors with the $text

It's almost there, just not sure why this is wrong.

<?php
$user = $_POST["PHP_AUTH_USER"];
$timestamp =date('d/m/Y H:i');
$text = "{$user} Logged in as: {$_SERVER['PHP_AUTH_USER']} at: {$timestamp} With IP: {$_SERVER['REMOTE_ADDR']
";]}
$file = fopen("./users.txt","a+ 
");
fwrite($file, $text);
fclose($file);
?>

Any help so that this saves and the page actually loads would be great. Thanks in advance.

图片转代码服务由CSDN问答提供 功能建议

我编写了脚本来捕获用户的IP地址,并使用时间捕获用户名 时间,但我已经尝试结合这些,我有一些错误的 $ text

它几乎就在那里,只是不知道为什么这是错的。

 &lt;?php 
 $ user = $ _POST [“PHP_AUTH_USER”]; 
 $ timestamp = date('d / m / YH:i'); \  n $ text =“{$ user}登录为:{$ _SERVER ['PHP_AUTH_USER']} at:{$ timestamp}使用IP:{$ _SERVER ['REMOTE_ADDR'] 
”;]} 
 $ file =  fopen(“./ users.txt”,“a + 
”); 
 nfwrite($ file,$ text); 
 nclclose($ file); 
?&gt; 
   \  n 
 

任何帮助,以便保存并实际加载页面会很棒。 提前致谢。

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • doushangxianq07480 2019-06-18 03:20
    已采纳

    This is a syntax error. The symbol ]} is at the end. It should be:

    $text = "{$user} Logged in as: {$_SERVER['PHP_AUTH_USER']} at: {$timestamp} With IP: {$_SERVER['REMOTE_ADDR']}
    ";
    
    点赞 打赏 评论

相关推荐 更多相似问题