I have made a website (https://sokk.ga/), and I want to log the users public ip whenever he/she clicks one of the links, and then redirect him/her to the correct url.
It's supposed to be a little php "script" between the main page and clicked link.
The problem i face is that it shows the php code as plain text in the browser (chrome), no redirect or log.
Here's my attempt:
<php?
date_default_timezone_set("Norway/Oslo");
$ipFile = fopen("../logg/ip.txt");
$ipText = time("Y.m.d" + "-" + "H:i:s") + "-" + $_SERVER['REMOTE_ADDR'] + "\n";
fwrite("$ipText", $ipFile);
fclose("../logg/ip.txt");
exit;
header("https://sokk.ga/skole/");
?>