php - Using a link and submit button to submit a form -
i working on website. website redirect index.php index.php?lang=en.
this because site multi-lingual , default language needs set english on home page. used header() method causes redirect loop site keeps reloading forever.
how can overcome barrier?
in php:
<?php // default english if $_get['lang'] isn't set $lang = isset($_get['lang']) ? $_get['lang'] : 'en'; // if language not in array of available languages, reset english if (!in_array($lang, array('en', 'es', 'fr'))) { $lang = 'en'; } header('location: index.php?lang=' . $lang); ?>
in html:
<a href="index.php?lang=en">english</a>, <a href="index.php?lang=es">español</a>, <a href="index.php?lang=fr">français</a>
Comments
Post a Comment