how to check for multi parameters in a url when printing the value or a link or selection
<p>when i have a link like this which can be longer but i've put a short version for my question.</p>

<pre><code>index.php?product=jeans&amp;gender=male&amp;lang=english
</code></pre>

<p>if the selection for the language looked like this</p>

<pre><code>&lt;select name="lang"&gt;
&lt;option value="&lt;?=$url;?&gt;"&gt;english&lt;/option&gt;
&lt;option value="&lt;?=$url;?&gt;"&gt;spanish&lt;/option&gt;
&lt;/select&gt;
</code></pre>

<p>for the url variable i'll have something like this.</p>

<pre><code>&lt;?php

if(isset($_GET['lang']))
{
    $lang = $_GET['lang'];
    if(isset($_GET['product']) &amp;&amp; !isset($_GET['gender']))
    {
        $product = $_GET['product'];
        $url = "index.php?product=".$product."&amp;lang=".$lang;
    }
    elseif(isset($_GET['product']) &amp;&amp; isset($_GET['gender']))
    {
        $product = $_GET['product'];
        $gender = $_GET['gender'];
        $url = "index.php?product=".$product."&amp;gender=".$gender."&amp;lang=".$lang;
    }
}
elseif(!isset($_GET['lang']))
{
    if(isset($_GET['product']) &amp;&amp; !isset($_GET['gender']))
    {
        $product = $_GET['product'];
        $url = "index.php?product=".$product."&amp;lang=english";
    }
    elseif(isset($_GET['product']) &amp;&amp; isset($_GET['gender']))
    {
        $product = $_GET['product'];
        $gender = $_GET['gender'];
        $url = "index.php?product=".$product."&amp;gender=".$gender."&amp;lang=english";
    }
}

?&gt;
</code></pre>

<p>as you can see it gets very messy. just to make sure the end-user is always on his/her correct page no matter what change is done in the param. what is the best way of doing this? im sick of checking soo much data just to make sure the end-user is on the correct page. how would you have had done this?</p>

<p>note: i havent written any functions to clean the gets i just wanted to write something clean so it is easy to read.</p>
