ok, I decided to try to search this before I asked this question, but no luck.
How can I keep output from getting removed when I click on a different button? It will only display output of one or the other. Where it displays the output is correct (underneath the button) I think whats causing this is when I click the second button it goes back to its original location (where the first output is) and I think that is why I can't display both outputs at the same time.
<!DOCTYPE html>
<html>
<body>
<form method="post" action="">
<p>
<input type="submit" value="Get Uptime" name="uptimebutton" >
<?php
if(isset($_POST['uptimebutton']))
{
//echo shell_exec('uptime');
$uptime = shell_exec('uptime');
echo "<pre>$uptime</pre>";
}
?></p>
<p><input type="submit" value="GRAB HDD INFO" name="memorybutton" >
<?php
if(isset($_POST['memorybutton']))
{
$output = shell_exec('df -h');
echo "<pre>$output</pre>";
}
?></p>
</form>
</body>
</html>
You can store them in session, or any other globally available variables. Something like this might help if you already have started a session:
<!DOCTYPE html>
<html>
<body>
<form method="post" action="">
<p>
<input type="submit" value="Get Uptime" name="uptimebutton"/>
<?php
if(isset($_POST['uptimebutton']))
{
$_SESSION['uptime'] = shell_exec('uptime');
}
echo "<pre>" . (isset($_SESSION['uptime']) ? $_SESSION['uptime'] : "") . "</pre>";
?>
</p>
<p>
<input type="submit" value="GRAB HDD INFO" name="memorybutton"/>
<?php
if(isset($_POST['memorybutton']))
{
$_SESSION['output'] = shell_exec('df -h');
}
echo "<pre>" . (isset($_SESSION['output']) ? $_SESSION['output'] : "") . "</pre>";
?>
</p>
</form>
</body>
</html>