ps2cho Posted December 7, 2006 Share Posted December 7, 2006 Hey guys,Is there a script that would show a certain link/text if the IP address matches one in the script?I simply want to have a post news button for me only...and i dont want to keep havign to type in the login in the address bar.Gotta keep the site clean :)Any way to do this?Thanks! Link to comment https://forums.phpfreaks.com/topic/29768-if-certain-ip-show-link/ Share on other sites More sharing options...
artacus Posted December 7, 2006 Share Posted December 7, 2006 Use $_SERVER[REMOTE_ADDR] Link to comment https://forums.phpfreaks.com/topic/29768-if-certain-ip-show-link/#findComment-136679 Share on other sites More sharing options...
ps2cho Posted December 7, 2006 Author Share Posted December 7, 2006 I know this is wrong as it errors out...but is it something like this:[code]<?php$ip = $_SERVER['REMOTE_ADDR'];if ($ip == "myiphere") echo "Link";else null;?>[/code] Link to comment https://forums.phpfreaks.com/topic/29768-if-certain-ip-show-link/#findComment-136688 Share on other sites More sharing options...
artacus Posted December 7, 2006 Share Posted December 7, 2006 missing {}'sand you need your IP address like 63.64.65.66 Link to comment https://forums.phpfreaks.com/topic/29768-if-certain-ip-show-link/#findComment-136691 Share on other sites More sharing options...
ps2cho Posted December 7, 2006 Author Share Posted December 7, 2006 [quote author=artacus link=topic=117682.msg480302#msg480302 date=1165468037]missing {}'sand you need your IP address like 63.64.65.66[/quote]Lol i realize how a IP looks...i didnt want my IP to be given out publically.But where do the {}'s go ?EDIT: wait nevermind im dumb :/ even after taking AP Computer Science....Asked friend to test for me and he said that he can see the word link..hmmEDIT2: Nvm he thought i meant in the AIM box :/ Link to comment https://forums.phpfreaks.com/topic/29768-if-certain-ip-show-link/#findComment-136695 Share on other sites More sharing options...
ps2cho Posted December 7, 2006 Author Share Posted December 7, 2006 Okay this is frustrating me...[code]<?php {$ip = $_SERVER['REMOTE_ADDR'];if ($ip == "68.xx.xx.xx") echo "<html><b><a href="http://xxx.no-ip.com/NewPage/news">Main News</a><br><a href="http://xxx.no-ip.com/NewPage/pages/journal/news">Journal News</a><br></html>";else null;}?>[/code]Why does this keep erroring out?[quote]Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in C:\wamp\www\NewPage\leftside.php on line 122[/quote] Link to comment https://forums.phpfreaks.com/topic/29768-if-certain-ip-show-link/#findComment-136707 Share on other sites More sharing options...
fert Posted December 7, 2006 Share Posted December 7, 2006 you didn't escape the quotes like this:[code]echo "<a href=\"www.somesite.com\">link</a>";[/code]and i don't this null is a valid PHP statement. Link to comment https://forums.phpfreaks.com/topic/29768-if-certain-ip-show-link/#findComment-136711 Share on other sites More sharing options...
bljepp69 Posted December 7, 2006 Share Posted December 7, 2006 Just cleaned up your code:[code]<?php $ip = $_SERVER['REMOTE_ADDR'];if ($ip == "68.xx.xx.xx") echo "<html><b><a href=\"http://xxx.no-ip.com/NewPage/news\">Main News</a><br><a href=\"http://xxx.no-ip.com/NewPage/pages/journal/news\">Journal News</a><br></html>";else null;?>[/code]Tested the above with my IP address, and it worked fine. Link to comment https://forums.phpfreaks.com/topic/29768-if-certain-ip-show-link/#findComment-136714 Share on other sites More sharing options...
ps2cho Posted December 7, 2006 Author Share Posted December 7, 2006 [quote author=bljepp69 link=topic=117682.msg480325#msg480325 date=1165472148]Just cleaned up your code:[code]<?php $ip = $_SERVER['REMOTE_ADDR'];if ($ip == "68.xx.xx.xx") echo "<html><b><a href=\"http://xxx.no-ip.com/NewPage/news\">Main News</a><br><a href=\"http://xxx.no-ip.com/NewPage/pages/journal/news\">Journal News</a><br></html>";else null;?>[/code]Tested the above with my IP address, and it worked fine.[/quote]Yep got it to work now. Thanks guys! Link to comment https://forums.phpfreaks.com/topic/29768-if-certain-ip-show-link/#findComment-136715 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.