Drop Down Select File And Include It into Same Page

前端 未结 1 732
小鲜肉
小鲜肉 2021-01-27 19:37

Tried to do this but it\'s only echoing the value not actually choosing the .php file to include into the same page. The code is below...


相关标签:
1条回答
  • 2021-01-27 20:16

    Change

    $path_file = $_SERVER['DOCUMENT_ROOT']/$file.php;
    

    to

    $path_file = $_SERVER['DOCUMENT_ROOT']."/".$file.".php";
    

    But this is very bad for security (you can't trust _POST data). Better change to something like:

    if (isset($_POST['select']) && $_POST['select'])
    {
    if ($_POST['select'] == 'something')
     include 'something.php';
    if ($_POST['select'] == 'somethingelse')
     include 'another.php';
    } else {
      include 'default.php';
    }
    
    0 讨论(0)
提交回复
热议问题