Ask coding questions

← Back to all posts
Ip Logger
MadMoneyMike (3)

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 (19277) [earned 5 cycles]
View Answer
Comments
hotnewtop
Coder100 (19277)

Found it!

read more

MadMoneyMike (3)

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

Coder100 (19277)

no, it will print it out @MadMoneyMike

MadMoneyMike (3)

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

MadMoneyMike (3)

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

Coder100 (19277)

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

Coder100 (19277)

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

MadMoneyMike (3)

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

Coder100 (19277)

just it won't be their exact IP @MadMoneyMike

MadMoneyMike (3)

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

MadMoneyMike (3)

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

<form action="names.txt" method="post"> <p>Favorite color?</p> <select> <option>Red</option> <option>Blue</option> <option>Green</option> </select> </input> <input type="submit"></input> </form>

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

@Coder100

Coder100 (19277)

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

Coder100 (19277)

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

MadMoneyMike (3)

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

ironblockhd (427)

Oh i also used neocities before replit

Coder100 (19277)

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

MadMoneyMike (3)

@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.

[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

Coder100 (19277)

sure, I'll send you php code @MadMoneyMike

Coder100 (19277)

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

MadMoneyMike (3)

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