HTML form submit to PHP -
okay have file called proxy.php these contents , want that, if of forms filled value , submitted, "if" check should become true , run commands have problem , though submit value, doesn't go "if" check. if put commands out of "if" check, start work not inside them.
<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'); ?>
the value $_post['hport1'] null because posting 'hport' html. try change.
if($_post['hport']){ echo $ssh->exec('ls'); echo $ssh->exec('screen -s proxy1 -x quit'); echo $ssh->exec('run these commands'); }
if problem still persists, use isset($_post['hport']) check whether value variable 'hport' set or not. can check post values mannually, use
<?php var_dump($_post); ?>
or
<?php echo '<pre>' . print_r($_post) . '</pre>'; ?>
for displaying $_post array values in readable format. hope you.
Comments
Post a Comment