Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/90.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Can';t按下编辑按钮时,保持下拉列表值处于选中状态_Php_Html - Fatal编程技术网

Php Can';t按下编辑按钮时,保持下拉列表值处于选中状态

Php Can';t按下编辑按钮时,保持下拉列表值处于选中状态,php,html,Php,Html,我已经在网上学习了很多关于这方面的教程,所以请不要让我先搜索,我已经搜索了,但仍然无法解决这个问题,这是我的完整代码: <?php include 'theme.php'; ceklogin(); $show=1; if($_POST['delete']){ $file_config=$_POST['config']; exec('rm -f /root/crt/'.$file_config); header( "refresh:0;url=vpn.php" );

我已经在网上学习了很多关于这方面的教程,所以请不要让我先搜索,我已经搜索了,但仍然无法解决这个问题,这是我的完整代码:

<?php
include 'theme.php';
ceklogin();
$show=1;
if($_POST['delete']){
    $file_config=$_POST['config'];
    exec('rm -f /root/crt/'.$file_config);
    header( "refresh:0;url=vpn.php" );
    exit;
    }

if($_POST['apply']){
    exec('grep use_config /root/config |awk -F"\'" \'{print $2}\'',$y);
    $use_config=$_POST['use_config'];
    $file_config=$_POST['config'];
    if ($use_config=='yes'){
    exec('vpn use-config yes',$var);
    exec('vpn file-config '.$file_config,$var);
    header( "refresh:0;url=vpn.php" );
    exit;
    }
    else{
    exec('vpn use-config no',$var);
    exec('vpn file-config '.$file_config,$var);

    if($y[0]=='yes'){
    header( "refresh:0;url=vpn.php" );
    exit;
    }else{
    $server=$_POST['server'];
    $user=$_POST['user']; 
    $pass=$_POST['pass'];
    exec('vpn server '.$server,$var3);
    exec('vpn user-pass '.$user.' '.$pass,$var3);    
    header( "refresh:0;url=vpn.php" );
    exit;
    }}}

css();

    echo "
         <form action=\"upload_crt.php\" method=\"post\"
         enctype=\"multipart/form-data\">
        <label for=\"file\">file:</label>
        <input type=\"file\" name=\"file\" id=\"file\">
        <input type=\"submit\" name=\"upload\" value=\"Upload\">
        </form>";

    exec('cat /root/user.txt',$out);
    exec('vpn server show',$var1);
    exec('vpn config-show',$h);
    echo "<form action=\"".$PHP_SELF."\" method=\"post\">";
    echo "</br>";
    exec('grep use_config /root/config |awk -F"\'" \'{print $2}\'',$y);
    if ($y[0]=='yes'){
    echo '<input type="checkbox" name="use_config" value="yes" checked>Use file Config<br><br>';
    exec('ls /root/crt |grep -i -e .ovpn -e .txt',$list);
    echo 'Config: <select name="config">';
    $x=0;
    while($x<count($list)){   
    if($list[$x]==$h[0]){
    echo "<option value=\"/root/crt/$list[$x]\" selected>$list[$x]</option>";}
    else{echo "<option value=\"/root/crt/$list[$x]\">$list[$x]</option>";}
    $x++;
    }
    echo '<input name="edit" type="submit" value="Edit">';
    echo "<input name=\"delete\" type=\"submit\" value=\"Delete\"/>";

}
    else{echo '<input type="checkbox" name="use_config" value="yes" >Use file Config';

    echo "<br><br>Server: <input type=\"text\" name=\"server\" value=\"$var1[0]\"/>";
    echo " <br><br>";
    echo "User--: <input type=\"text\" name=\"user\" value=\"$out[0]\"/>";
    echo "<br><br>";
    echo "Pass--: <input type=\"password\" name=\"pass\" value=\"$out[1]\"/>";}
    echo "<br><br><input name=\"apply\" type=\"submit\" value=\"Apply Settings\"/>";
    echo '</form>';

if($_POST['edit']){
    $show=2;
    }
if ( $show == 1 )
{
if(isset($_POST["update"])) {
    file_put_contents($_POST['filename'], $_POST["akunvpn"]);
    $show=1;
    echo "<br><b><font color=\"green\">The file has been updated</font></b>";
 }
echo '<br><div style="font-size: 13px; word-wrap: break-word; width:400px;height:70px;border:0px solid #000;text-align:left; overflow-y: scroll;">
<b>NOTICE:</b> If you want your internet to be automatically reconnected when OpenVPN gets disconnected, add these lines in your *.ovpn :<br>
script-security 2 <br>
up client-connect.sh';
}
else {
    $filename = $_POST["config"];
    $filecontent = file_get_contents($filename);
    $nameonly = str_replace('/root/crt/', '', $filename);
    echo '<br><b><font color="green">Now editing: '.$nameonly.'</font></b>
    <br>
    <form action="" method="post">
    <textarea name="akunvpn" autofocus rows="12" cols="69" style="font-family: Arial;font-size: 9pt;">';
    echo htmlentities($filecontent);
    echo '</textarea><br><br>
    <input type="hidden" name="filename" value="'.$filename.'">
    <input name="update" type="submit" value="Update File">
    </form>
    '; //echos file content in textarea.
}
echo '
</div>
</div>';
foot();
echo '
</div>
</body>
</div>
</html>';
?>

我不知道你在问什么。你能说清楚点吗?另外,您似乎没有真正使用
$show
做任何事情,而且我似乎找不到
$h
来自哪里。
$h
来自哪里?那么
$list
呢?
$h[0]
是否曾经等于
$list[$x]
if($_POST['edit']){
    $show=2;
    echo '<option value="/root/crt/'.$_POST["update"].' selected >'.$_POST["update"].'</option>';
   }