Q:

Capture username with IP and time in 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']\n";]}
$file = fopen("./users.txt","a+ \n");
fwrite($file, $text);
fclose($file);
?>

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

A:

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']}\n";

