
Untitled
By: a guest on
Aug 8th, 2012 | syntax:
None | size: 0.64 KB | hits: 5 | expires: Never
php Switch between two includes
// ...
if(isset($_POST['page_option']))
{
$fp = fopen('data.txt', 'w');
if($_POST['page_option'] == 'go1')
$write = '1';
else if($_POST['page_option'] == 'go2')
$write = '2';
fwrite($fp, $write);
fclose($fp);
}
<form action="" method="post">
<select name="page_option">
<option value="go1">Go 1</option>
<option value="go2">Go 2</option>
</select>
<input type="submit" value="Change index.php" />
</form>
$fp = fopen('data.txt', 'r');
$contents = fread($fp, filesize('data.txt'));
fclose($fp);
if($contents == '1')
include('go1.php');
else if($contents == '2')
include('go2.php');
else
echo 'Something else...';