Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 8th, 2012  |  syntax: None  |  size: 0.64 KB  |  hits: 5  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. php Switch between two includes
  2. // ...
  3. if(isset($_POST['page_option']))
  4. {
  5. $fp = fopen('data.txt', 'w');
  6. if($_POST['page_option'] == 'go1')
  7. $write = '1';
  8. else if($_POST['page_option'] == 'go2')
  9. $write = '2';
  10. fwrite($fp, $write);
  11. fclose($fp);
  12. }
  13.  
  14. <form action="" method="post">
  15. <select name="page_option">
  16. <option value="go1">Go 1</option>
  17. <option value="go2">Go 2</option>
  18. </select>
  19. <input type="submit" value="Change index.php" />
  20. </form>
  21.        
  22. $fp = fopen('data.txt', 'r');
  23. $contents = fread($fp, filesize('data.txt'));
  24. fclose($fp);
  25. if($contents == '1')
  26. include('go1.php');
  27. else if($contents == '2')
  28. include('go2.php');
  29. else
  30. echo 'Something else...';