hugh90 Posted August 13, 2006 Share Posted August 13, 2006 Hi, I’m very bad at php and I need your expertise please.Example, this is how my files are linked.>> www.site.com/?id=file/file/pageThis is a very bad linking system and so inflexible, it only works as long as pages are literally the same as the above example URL is.But if I were to install a php script (formmail script, quiz scripts, etc..) basically anything that requires submission, a link to be pressed, scripts that require .include codes' to be placed in my php pages, then it doesn’t work and goes back to homepage.php (as specified in the code below).I’m guessing this happens because the link by those php scripts generate a link/url to a requested file (that even already exists and should link it) but fails to work since it only reads url’s that are coded as the above example.I also think the php coding below is also to blame, for some reason it thinks the whole php scripting/linking world revolves around URL’s that are linked such as the above example.This is what I have in the index.php page where I want the dynamic pages to show:<?phpIf(file_exists($_GET['id'].".php")){include($_GET['id'].".php");}else{include("homepage.php");}?>Please fix the above code (or do anything) so that it is more flexible. ???Thank you. Quote Link to comment Share on other sites More sharing options...
onlyican Posted August 13, 2006 Share Posted August 13, 2006 www.site.com/?id=file/file/page/ is for a new folderif you want the variablesID = FILEFile = PAGEwhich I think if your goalthenwww.site.com/?id=file&file=page Quote Link to comment Share on other sites More sharing options...
redarrow Posted August 13, 2006 Share Posted August 13, 2006 url from a index page or any page properly.know we no that we have set in the link this condition cmd=filewe know goto the page to get that condition.[code]<a href="where_ever.php?cmd=file">go to the file </a>[/code]this is on the page that the what_ever link points to.[code]<?phpif($_GET['cmd']=="file"){what ever you want to do with the match from the link}else{echo " sorry your link did not match this condition";}?>[/code][b]ps be very careful when playing around with the $_GET satament as it is only secure as shown above with a condition set ok.[/b] Quote Link to comment Share on other sites More sharing options...
hugh90 Posted August 13, 2006 Author Share Posted August 13, 2006 [quote author=redarrow link=topic=104064.msg414926#msg414926 date=1155463136][code]<?phpif($_GET['cmd']=="file"){what ever you want to do with the match from the link}else{echo " sorry your link did not match this condition";}?>[/code][/quote]Do I just straight replace the above code with my code below?[code]<?phpIf(file_exists($_GET['id'].".php")){include($_GET['id'].".php");}else{include("homepage.php");}?>[/code]Sorry my understanding of php is non-existent :( 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.