php switch between two includes

Discussion in 'PHP' started by ska_defender, Jul 29, 2012.

  1. #1
    I have 4 files admin.php index.php go1.php and go2.php admin.php needs to be connected with index.php in admin.php when I click on go1 button or option then index.php will show the contents of go1.php otherwise it will show the contents of go2.php I thought about using either switch or if statements, but I have no clue where to begin.

    index.php is the page as seen by public whereas admin.php is private so through admin.php I want to control index.php to switch between contents of go1.php and go2.php

    Any tutorial or help please
     
    ska_defender, Jul 29, 2012 IP
  2. sarahk

    sarahk iTamer Staff

    Messages:
    28,899
    Likes Received:
    4,555
    Best Answers:
    123
    Trophy Points:
    665
    #2
    try something like this
    
    $buttonvalue = $_GET['button-name'];
    
    switch($buttonvalue) {
       case 'go1':
         include 'go1.php';
         break;
       case 'go2':
         include 'go2.php';
         break;
    }
    
    PHP:
    The admin page doesn't get involved unless you need the ability to change the content that you show the user but that doesn't sound likely.
     
    sarahk, Jul 29, 2012 IP