Created
May 18, 2022 18:40
-
-
Save FernandoCutire/b7061e731d522f97107f635f22a3e412 to your computer and use it in GitHub Desktop.
Saved from https://stackoverflow.com/questions/7791126/how-to-create-a-simple-php-cookie-language-toggle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form action="language_switcher.php" method="post"> | |
<select name="lang"> | |
<option value="en"<?php if( $_COOKIE["language"] == "en" ) { echo " selected"; } ?>>English</option> | |
<option value="ru"<?php if( $_COOKIE["language"] == "ru" ) { echo " selected"; } ?>>Russian</option> | |
</select> | |
<input type="submit" value="Select Language"> | |
</form> | |
<p>Language: <?php if( isset( $_COOKIE["language"] ) ) { echo $_COOKIE["language"]; } else { echo "<em>not set</em>"; } ?></p> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment