Skip to content
← Back to Community
Ip Logger
Profile icon
MadMoneyMike

How can i make an IP logger so i can make a chat on my website and ban anyone that is misbehaving. Im not hosting the site on repl.it though I'm using neocities.org but if i have to ill transfer the site here.

Answered by Coder100 [earned 5 cycles]
View Answer
Voters
Profile icon
aleqsiatuka
Profile icon
Unknown628
Profile icon
thekingofhacks7
Profile icon
Leroy01010
Profile icon
MadMoneyMike
Comments
hotnewtop
Profile icon
Coder100

Found it!

<?php echo 'User IP - ' . $_SERVER['REMOTE_ADDR']; ?>

read more

Profile icon
MadMoneyMike

Will that just send it into another file like [email protected]

Profile icon
Coder100

no, it will print it out @MadMoneyMike

Profile icon
MadMoneyMike

Print it out where? To the user that opened the the site? And do i have to make a new file with .php at the end or do i put that in index.html?
@Coder100

Profile icon
Coder100

in a new php repl. @MadMoneyMike

Profile icon
MadMoneyMike

alright! Ill try that
@Coder100

Profile icon
Coder100

good luck! @MadMoneyMike

Profile icon
MadMoneyMike

i tried that but i get an ip that is not mine. @Coder100

Profile icon
Coder100

yeah, it goes through a proxy so you can't be entirely accurate @MadMoneyMike

Profile icon
Coder100

it's also a security thing, this could be used for scamming you know @MadMoneyMike

Profile icon
MadMoneyMike

so if i tried to ip ban someone then it wouldn't [email protected]

Profile icon
Coder100

@MadMoneyMike it would

Profile icon
Coder100

just it won't be their exact IP @MadMoneyMike

Profile icon
MadMoneyMike

Awesome! Thx so much! Im on my schools Chromebook i just got bc corona and im making a website that me and my friends can chat on and bc its gonna be viewable by my principle and teachers and i need to make sure that i can ban anyone that says anything bad such as profanity.(im in 8th grade) @Coder100

Profile icon
Coder100

@MadMoneyMike yey good luck!

Profile icon
MadMoneyMike

umm... is it possible you can help me with one more thing?
I have a form like

Favorite color?

Red Blue Green

and i dont understand...how do i get it to send the favorite color to another file?

@Coder100

Profile icon
Coder100

@MadMoneyMike oh, make it go to somewhere else, like /name.php

Profile icon
Coder100

and then in /name.php you can process form data and write to the file from there. @MadMoneyMike

Profile icon
MadMoneyMike

oh... i tried /names.txt but it didnt work it just brought to that page then i tried names.php and it brought me to a "page not found" @Coder100

Profile icon
WillEngbrecht

python? @Coder100

Profile icon
ironblockhd

Oh i also used neocities before replit

Profile icon
MadMoneyMike

welp

Profile icon
Coder100

You can't do it with HTML. You need a backend in order to process the request.

Profile icon
MadMoneyMike

@Coder100 well then..can you help me make it in php or something? Im new to coding and tbh i only know some html and css. Or possibly help me make like a chat box or comments of some tpe so people can chat. Im sorr if i am asking for too much help.

Profile icon
[deleted]

replits backend actually doesn't allow to get your ip, you need to get it on the clientside from http://ip-api.com/json and then send it to your server

Profile icon
Coder100

sure, I'll send you php code @MadMoneyMike

Profile icon
Coder100

Yeah, I'm aware of the IP not being accurate, but in his case, it doesn't have to be exact @behavingEffort

Profile icon
MadMoneyMike

well...i dont have any. i dont know a single thing about php @Coder100

Profile icon
Coder100