dongtui8593 2015-06-17 18:17
浏览 13

自动化PHP包括[关闭]

i am looking for a way to automatize my php script, it should search for php files in a folder called SUBPAGES and include the php files with the Help of a Dropdown like my example but without recoding it everytime i add a new file.

It should find the files stored in the SUBPAGES folder by itself and include the selected file automatized.

Can any one please help me in solving it.

<html>

<body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0">

<div align="center">
<table border="0" width="100%" cellspacing="0" cellpadding="0" height="100%">
<tr>
<td align="center">
<table border="0" cellspacing="0" cellpadding="0" width="" height="">
<tr>
<td width="300" height="50" bgcolor="#F2F2F2">

<p align="center">

<form name="form">
<p align="center">
<select name="link" SIZE="1" onChange="window.location.href = document.form.link.options[document.form.link.selectedIndex].value;">
<option value="#" style="display:none">Choose</option>
<option value="index.php?id=page1"> Seite1 </option>
<option value="index.php?id=page2"> Seite2 </option>
</select></p>
</form>

</td>
</tr>
<tr>
<td height="20" bgcolor="#999999">&nbsp;</td>
</tr>
<tr>
<td height="350">

<?php
error_reporting(0);
switch($_GET['id']) {
default:
include('Subpages/page1.php');
break; case "page2":
include('Subpages/page2.php');
}
?>

</td>
</tr>
</table>
</td>
</tr>
</table>
</div>

</body>

</html>
  • 写回答

2条回答 默认 最新

  • dousi4472 2015-06-17 18:32
    关注

    Simple way. firstly check the type of security, after include

    $page = 'Subpages/page'.settype($_GET['id'],'integer').'.php' ;
    $defaultpage = 'Subpages/page1.php' ;
    if (file_exists($page)) {
            include($page);
    }else{
     include($defaultpage);
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 关于用pyqt6的项目开发该怎么把前段后端和业务层分离
  • ¥30 线性代数的问题,我真的忘了线代的知识了
  • ¥15 有谁能够把华为matebook e 高通骁龙850刷成安卓系统,或者安装安卓系统
  • ¥188 需要修改一个工具,懂得汇编的人来。
  • ¥15 livecharts wpf piechart 属性
  • ¥20 数学建模,尽量用matlab回答,论文格式
  • ¥15 昨天挂载了一下u盘,然后拔了
  • ¥30 win from 窗口最大最小化,控件放大缩小,闪烁问题
  • ¥20 易康econgnition精度验证
  • ¥15 msix packaging tool打包问题