Jump to content

Recommended Posts

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/");

?>

1. Your code needs to open with <?php

2. Your timezone is invalid, use

date_default_timezone_set("Europe/Oslo");

3. If you exit before the redirect, how can it redirect?

4. The concatenation operator in php is "." and not "+"

I recommend you turn error reporting on.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.