【发布时间】:2014-02-26 19:01:01
【问题描述】:
尝试这样做,但它只是回显值,而不是实际选择要包含到同一页面中的 .php 文件。代码如下...
<body>
<form name="form1" method="POST" action="test.php">
<select name="select" onChange="document.form1.submit()">
<option selected>Select an Industry</option>
<option value="members">members</option>
<option value="Female">Female Members</option>
</select>
</form>
<?php
$file = $_POST['select'];
echo $file;
$path_file = $_SERVER['DOCUMENT_ROOT']/$file.php;
if(file_exists($path_file))
{
echo("The file does not exist at: $path_file");
}
else
{
require_once($path_file);
}?>
</body>
一旦排序,我希望它会在同一页面中包含一个 php 文件!在更改之前还需要一个默认页面,所以成员是主页面,然后人们可以选择女性来查看女性等。
【问题讨论】:
-
这两个代码块是否在同一个页面上?
-
是的,它通过 echo $file 回显值;所以也需要包含它