New on LowEndTalk? Please Register and read our Community Rules.
Php script help
Can someone please help me to create a simple script to show results per IP?
Ex: if the request comes from IP 188.8.131.52 and this ip is added in the list should show this output: 11111
If the request comes from a IP that is not incluced in the list should show this output: 22222
Am searching in google but nothing can find.
P.s should be a PHP not .htaccess.
Thank you guys!
Switch the echo to 111111, but that's a snippet of what I think you're looking for.
Something like this?
I don't think that's correct. The $_SERVER superglobal is an array, so it can't be compared to a string like that. @theroyalstudent's example looks good.
This one is great but cant add more then 1 ip. Am trying with commas also in a new line but wont work . Also if is possible to show different result per ip will be perfect!!!!
Maybe you need a database for that? Or you could work out something like an IP per line, in this format:
I would just use a database though, if the dataset is gonna get bigger as time pasts.
Well he's exploding based on a new line so you should have something like
in your text file and it should work fine.
Cant create database due to lack of knownledge
Is not working. Only the first IP works but not others
Here you go, use PHP_EOL instead;
Thank you but cant figure it out. Just to add that line in your script?
Or \n in double quotes. Since '\n' is literally just
Thanks - saved me from typing the code on my tablet, haha.
Yeah the double quotes did the trick!!! Thanks.
Thank you guys for the help! You are great!!!!
@theroyalstudent No worries mate!