Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have shell script which I run like this

/var/www/test.sh 2015

or

/var/www/test.sh 2014

When this script runs, it actually takes data from freeradius and generates gnuplot base graph for the specific year in the www folder like

/var/www/output.jpg 

Now I want to make a php drop down menu with years like 2015, 2014 and so on, and when user select any year, it should run the script with the specific choice year. But how can I pass year to the shell script.

so far I have tried this but its not working.

root@rm:/var/www# cat test5.php

<html>
<head><title>some title</title></head>
<body>
  <form method="post" action="">
    <input type="text" name="something" value="<?= isset($_POST['something']) ? htmlspecialchars($_POST['something']) : '' ?>" />
    <input type="submit" name="submit" />
  </form>

<?php
if(isset($_POST['submit'])) {
echo ($_POST['something']);
// Now the script should be executed with the selected year 
      $message=shell_exec("/var/www/test.sh $something");
// and after executing the script, this page should also open the output.jpg in the browser

}
?>
</body>
<html>
root@rm:/var/www#
share|improve this question
    
Take a look at: stackoverflow.com/a/9612273/3776858 –  Cyrus Jun 17 at 5:45

1 Answer 1

Drop down menu in html is a select.

<form method="post" action="">
    <select name="something">
        <option value="2014">year 2014</option>
        <option value="2015">year 2015</option>
    </select>
    <input type="submit" name="submit" />
</form>

Then after submit

$something = $_POST["something"];
shell_exec("/var/www/test.sh $something");
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.