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! Quote Link to comment Share on other sites More sharing options...
artacus Posted December 7, 2006 Share Posted December 7, 2006 Use $_SERVER[REMOTE_ADDR] Quote Link to comment 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] Quote Link to comment 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 Quote Link to comment 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 :/ Quote Link to comment 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] Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.