Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to prevent the set of a get variable?
    text
    copied!<p>I have a question. Let me explain this with an example. I have this piece of code:</p> <pre><code>&lt;form action="vehicles.php" method="get"&gt; &lt;span&gt;Marca: &lt;select name="brand"&gt; &lt;option value="null" selected="selected"&gt;&lt;/option&gt; &lt;option value="Volkswagen"&gt;Volkswagen&lt;/option&gt; &lt;option value="Renault"&gt;Renault&lt;/option&gt; &lt;option value="Peugeot"&gt;Peugeot&lt;/option&gt; &lt;option value="Fiat"&gt;Fiat&lt;/option&gt; &lt;/select&gt; &lt;/span&gt; &lt;span&gt;Modelo: &lt;select name="model"&gt; &lt;option value="null" selected="selected"&gt;&lt;/option&gt; &lt;option value="206"&gt;206&lt;/option&gt; &lt;option value="Suran"&gt;Suran&lt;/option&gt; &lt;option value="Passat"&gt;Passat&lt;/option&gt; &lt;option value="Punto"&gt;Punto&lt;/option&gt; &lt;/select&gt; &lt;/span&gt; &lt;input type="submit"&gt; &lt;/form&gt; </code></pre> <p>Is any way to prevent the assignment of those variables if the option selected is the "null" one?</p> <p>If, for example, I select brand="Renault" and model="null" the url is</p> <p><code>http://mywebpage.com/vehicles.php?brand=Renault&amp;model=null</code></p> <p>but it should be</p> <p><code>http://mywebpage.com/vehicles.php?brand=Renault</code></p> <p>I know how to unset the variables with "null" value after the form submission with PHP. Is any way to do it before the submission and after the variables are setted to "null". I would like a cleaner url, free of "variable=null" results.</p> <p>P/D: I don't have a native english speaking so feel free to edit my question. I wish you understand me.</p>
 

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