have to double click a form button to make this work
Hello webassist team im building a websiute that is multi language, spanish and english, im trying to use the cookies toolkit to acomplish this instead of a link, i build a form with 2 input image buttons flags for each language, i added the set cookie value to detect when each of these are clicked but i have to double or click twice in order for the cookie to work, my point is that the text called from the database will be filtered depending on wich cookie value is selected.
Why do i have to double click what am i doing wrong why cant it work with just a single click over the buttons.
Please help
<?php
if (isset($_POST["en_x"])) {
setcookie("lengua", "".((isset($_POST["eng"]))?$_POST["eng"]:"") ."", time()+(60*60*24*30), "/", "", 0);
}
?>
<?php
if (isset($_POST["es_x"])) {
setcookie("lengua", "".((isset($_POST["esp"]))?$_POST["esp"]:"") ."", time()+(60*60*24*30), "/", "", 0);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script src="../WA_Cookies/Cookies.js"></script>
</head>
<body>
<div id="Logo"><a href="../index.php"><img src="../images/logo.png" alt="Vianpower" width="115" height="68" border="0" /></a></div>
<div id="Navegacion">
<div align="right"><form method="post" action="<?php echo (htmlentities($_SERVER["PHP_SELF"]));?><?php echo(isset($_SERVER['QUERY_STRING'])?"?".str_replace("<","%3C",str_replace(">","%3E", str_replace('"',"%22", $_SERVER['QUERY_STRING']))):""); ?>" id="lan" name="lan">
<div class="languagechoice">
<input type="image" name="en" src="../images/flagsus.gif" />
<input type="image" name="es" src="../images/flagses.gif" />
</div>
</form>
</div>