kriffer Posted June 22, 2006 Share Posted June 22, 2006 im new to php, im just learnin this and css .. i tried to do somethig which i thought was simple but am having a problem with... ok heres the problem.. im makin a menu.. but the files arent coming up on the page when you click on the link so this is my menu[code]<div id="navcontainer"><ul id="navlist"><li id="active"><a href="?" id="current">Home</a></li><li><a href="forums">Forums</a></li><li><a href="?x=servers">Servers</a></li><li><a href="?x=matches">Matches</a></li><li><a href="?x=about_us">About Us</a></li></ul></div>[/code]and this is the php in my page[code]<?phpif($x=="" ){include"home.php";}else{include"$x.php";}?>[/code]so now when i want to goto the Servers page or the Matches page, it just displays it in the url like this[code]http://www.kriffer.biz/beta/?x=servers[/code]so whats the problem? Quote Link to comment https://forums.phpfreaks.com/topic/12612-help/ Share on other sites More sharing options...
.josh Posted June 22, 2006 Share Posted June 22, 2006 cuz that's what you put in the href in your link tags. try adding [b]index.php[/b]?x=servers etc.. or whatever your main page (home, index, whatever) is. Quote Link to comment https://forums.phpfreaks.com/topic/12612-help/#findComment-48361 Share on other sites More sharing options...
kriffer Posted June 22, 2006 Author Share Posted June 22, 2006 ok that worked. yess. but now take for example this site.... www.mwnx.net click on either downloads or network it doesnt matter. look at the url... it doesnt include like index.php or downloads.php like , now that i just inserted the page it shows up like this sites url with index.php?showtopic=96453 Quote Link to comment https://forums.phpfreaks.com/topic/12612-help/#findComment-48364 Share on other sites More sharing options...
.josh Posted June 22, 2006 Share Posted June 22, 2006 please try to explain your question a little more. i don't think i fully understand what you mean. Quote Link to comment https://forums.phpfreaks.com/topic/12612-help/#findComment-48366 Share on other sites More sharing options...
kriffer Posted June 22, 2006 Author Share Posted June 22, 2006 ok goto www.kriffer.biz/beta .... ok the whole point of [code]<?phpif($x=="" ){include"home.php";}else{include"$x.php";}?>[/code] this was to keep the banner and footer not change at all.. and only that content the "include' i.e. include"home.php"; change only that data.. so if you clicked on servers or something else on that menu.. it will go and display the data.. right now it just links to the files i just want it to change the inside data the content that says servers. or matches. or about us. or whatever.. Quote Link to comment https://forums.phpfreaks.com/topic/12612-help/#findComment-48376 Share on other sites More sharing options...
.josh Posted June 22, 2006 Share Posted June 22, 2006 okay so let's say you have an index.php and it has 3 sections:example index.php[code]<html><head></head><body><!-- header content: let's put your links here, as an example --><div> <a href = 'index.php?x=home'>home</a> | <a href = 'index.php?x=forum'>forum</a> | <a href = 'index.php?x=contact'>contact</a></div><!-- main content --><div> <?php if ($_GET['x']) { include($_GET['x'] . '.php'); } else { include('home.php'); } ?></div><!-- footer content --><div> footer stuff here</div></body></html>[/code]now, this is just a simple example. there are some major security flaws in this. for example, you will at the very least want to create an array of acceptable values of x and only include ($_GET['x'] . '.php'); if $_GET['x'] matches one of the values in the array. Quote Link to comment https://forums.phpfreaks.com/topic/12612-help/#findComment-48378 Share on other sites More sharing options...
kriffer Posted June 22, 2006 Author Share Posted June 22, 2006 ok remember im new to all this.. but ok.. see that php looks different then the php i had in there.. so thats what your suggesting i go with and ok here if this helps any better.. what i was trying to do was create one page with dynamic content Quote Link to comment https://forums.phpfreaks.com/topic/12612-help/#findComment-48379 Share on other sites More sharing options...
.josh Posted June 22, 2006 Share Posted June 22, 2006 well my coding style is slightly different from yours. the point of my example was to look at how it's placed. the only thing i really see [i]wrong[/i] with your actual code is $x is not the same as $_GET['x']; (unless your register globals are on, i think...) but in either case, you need to be using $_GET['x'] not $x, even if it does work. also, this:if($x == "") is not the same as this:if ($x)the first one will include your home.php only if someone clicks on a link that has index.php?x=notice no value after it. it will not include home.php if they simply typed index.php in the url, because your condition will only be true if x is set, and equal to "". Quote Link to comment https://forums.phpfreaks.com/topic/12612-help/#findComment-48380 Share on other sites More sharing options...
kriffer Posted June 22, 2006 Author Share Posted June 22, 2006 i see.. well the forums have done me good already... this line you type first time i put it in my code while you were replying and it works.. this line [code] <?php if ($_GET['x']) { include($_GET['x'] . '.php'); } else { include('home.php'); } ?>[/code] worked.. thxnk alot i'll be back on tommorow Quote Link to comment https://forums.phpfreaks.com/topic/12612-help/#findComment-48382 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.