좋아요.이 내용으로 proxy.php라는 파일을 가지고 있는데, 그 중 어떤 형식이 값으로 채워져 제출되면 "if"체크 사실이되어야하고 명령을 실행해야하지만 문제가 있으며 값을 제출하더라도 "if"체크에 포함되지 않습니다. 명령을 "if"체크에서 제외하면 작동하지만 내부에서는 작동하지 않습니다.HTML 양식을 PHP로 제출
<html>
<body>
<br>
<form action="proxy.php" method="post">
<br>
Host Port 1: <input type="text" name="hport" />
Server Port 1: <input type="text" name="sport"/>
<br>
Host Port 2: <input type="text" name="hport2"/>
Server Port 2: <input type="text" name="sport2"/>
<br>
<input type="submit" />
</form>
</body>
</html>
<?php
include('Net/SSH2.php');
$_POST["ip"]="iphere";
$_POST["pass"]="passhere";
$ssh = new Net_SSH2($_POST["ip"]);
if (!$ssh->login('root', $_POST["pass"])) {
exit('Login Failed');
}
if($_POST['hport1']){
echo $ssh->exec('ls');
echo $ssh->exec('screen -S Proxy1 -X quit');
echo $ssh->exec('Run these commands');
}
if($_POST['hport2']){
echo $ssh->exec('ls');
echo $ssh->exec('screen -S Proxy2 -X quit');
echo $ssh->exec('Run these commands');
}
echo $ssh->exec('exit');
?>
그것은 전체 문제가되지 않을 수도 있지만 양식의 입력은'hport'이다; 당신의 코드는'hport1'을 찾고 있습니다. – andrewsi
그리고 양식을 제출할 때 $ _POST [ 'hport']의 값은 무엇입니까? – Axarydax
PHP를 한동안 사용해 본 적이 없지만 사용할 수있는 기능은 없습니까? –