Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>To expand on jwheel12's answer. The form action will work as a relative path without http:// in it. Therefore appending your action="" to the current URL. Use an absolute path if possible.</p> <pre><code>&lt;form action="http://www.example.com/english/404.php&lt;?php echo ( $_SERVER['QUERY_STRING'] )? "?".$_SERVER['QUERY_STRING']) : "" );?&gt;" method="post"&gt; </code></pre> <p>or alternatively you could pass the variables as a hidden input type</p> <pre><code>foreach ($_GET as $key =&gt; $value) { echo '&lt;input type="hidden" name="'.$key.'" value"'.$value.'"&gt;'; } </code></pre> <p>I like to use a custom function like the one below that will loop through all the items in the array "$ary" and return the last one that is not empty.</p> <pre><code>$myVariable = getVar('myVariable'); function getVar($var) { $ary = array('_SESSION', '_COOKIE', '_POST', '_GET'); foreach ($ary as $a) { if ($GLOBALS[$a][$var] != '') { $return = $GLOBALS[$a][$var]; }; }; return $return; }; </code></pre> <p>Finally you could use preg_replace with a hyper link if you just want to toggle between 2 languages</p> <pre><code>$currentURL = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; if (preg_match('/german/i', $currentURL)){ $newURL = preg_replace('/german/i', 'english',$currentURL); $currentLanguage = "german"; } else { $newURL = preg_replace('/english/i', 'german',$currentURL); $currentLanguage = "english"; }; echo '&lt;a href ="'.$newURL. '"&gt;'($currentLanguage == "german"? "View in English": "Sehen Sie auf Deutsch";). '&lt;/a&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