skeg0 Posted March 27, 2006 Share Posted March 27, 2006 im wondering if anyone can help me as im new to php.I have a database driven php webpage that contains a menu at the top of each page called "top_template.php".. when a link is clicked to load a new page, it automatically reloads this "top_template" with a --- require "top_template.php"; --- command in the main body part of the page. however, there will be some times when i need to load up a different menu at the top depending on what the previous page was. so i was wondering if php has commands in it that will allow for an IF statement along the following lines:if the referer (the page link that referred to this new page) == "menu1.php" THENrequire "menu2.php" ELSE require "menu1.php"orif menu2 is visible THEN require "menu2" ELSErequire menu1it is just the direct syntax of these statements i need as it is written above, if anyone could help me i would be extremely grateful!! Link to comment https://forums.phpfreaks.com/topic/5920-i-need-an-if-statement/ Share on other sites More sharing options...
Barand Posted March 27, 2006 Share Posted March 27, 2006 [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]if the referer (the page link that referred to this new page) == "menu1.php" THENrequire "menu2.php" ELSE require "menu1.php"orif menu2 is visible THEN require "menu2" ELSErequire menu1[/quote][code]if ($referer == 'menu1.php') $req_menu = 'menu2.php';else $req_menu = 'menu1.php';//OR$req_menu = ($referer == 'menu1.php') ? 'menu2.php' : 'menu1.php';[/code] Link to comment https://forums.phpfreaks.com/topic/5920-i-need-an-if-statement/#findComment-21158 Share on other sites More sharing options...
skeg0 Posted March 27, 2006 Author Share Posted March 27, 2006 [!--quoteo(post=358851:date=Mar 27 2006, 01:14 PM:name=Barand)--][div class=\'quotetop\']QUOTE(Barand @ Mar 27 2006, 01:14 PM) [snapback]358851[/snapback][/div][div class=\'quotemain\'][!--quotec--][code]if ($referer == 'menu1.php') $req_menu = 'menu2.php';else $req_menu = 'menu1.php';//OR$req_menu = ($referer == 'menu1.php') ? 'menu2.php' : 'menu1.php';[/code][/quote]thanks very much.. do i have to define these variables somewhere? the $referer and $req_menu or are they already known by php? Link to comment https://forums.phpfreaks.com/topic/5920-i-need-an-if-statement/#findComment-21162 Share on other sites More sharing options...
Barand Posted March 27, 2006 Share Posted March 27, 2006 $req_menu is defined in the above code.$referer will need to be defined by your program (prob from processing $_SERVER['HTTP_REFERER'] variable). Link to comment https://forums.phpfreaks.com/topic/5920-i-need-an-if-statement/#findComment-21274 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.