Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The <a href="http://www.w3.org/TR/html401/interact/forms.html#adef-action" rel="nofollow">action attribute</a> of a form expects a URI to be specified. Instead, there is a <a href="http://www.php.net/manual/en/function.exec.php" rel="nofollow">exec</a> function which returns a string. I'm assuming this string is not a valid URI. So in the source of the html it will look something like this:</p> <pre><code>&lt;form action=some string returned by exec&gt; </code></pre> <p>What is happening is the following:</p> <ol> <li>The page is loaded</li> <li>exec('sed....') is processed and the result is put in the html</li> <li>User clicks submit and is taken to the URI specified in action. In this case it is the last line from the result of exec('sed....')</li> </ol> <p>I recommend that you simplify this by changing the form to post to another page <code>&lt;form action="changeFile.php"&gt;</code> then in changeFile.php add logic to modify the VPS file.</p> <p>For example, in changeFile.php add logic to change the content with something like this:</p> <pre><code>&lt;?php exec("sed -i 's/animal=*/animal=$_REQUEST['type']/g' /home/user1234/animals/file.props"); echo 'file modified' ?&gt; </code></pre> <p>This could also be accomplished by having the page post to itself with something like the following:</p> <pre><code>&lt;?php ini_set('display_errors', 1); ini_set('error_reporting', E_ALL); if(!empty($_REQUEST['animal_type'])){ exec('sed -i '.escapeshellarg('s/animal=*/animal='.$_REQUEST['animal_type'].'/g')." /home/user1234/animals/file.props"); echo 'File has been updated'; } ?&gt; &lt;form method="post" action="&lt;?php echo $_SERVER['PHP_SELF']; ?&gt;"&gt; &lt;select name="animal_type"&gt;; &lt;option value="true"&gt;bat&lt;/option&gt;; &lt;option value="false"&gt;fish&lt;/option&gt;; &lt;option value="cat"&gt;cat&lt;/option&gt;; &lt;option value="dog"&gt;dog&lt;/option&gt;; &lt;/select&gt; &lt;input type="submit" name="Submit" value="Submit" /&gt; &lt;/form&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload