Answer the question
In order to leave comments, you need to log in
Print values from $_POST and $_COOKIE?
Good day!
I got confused with the task of displaying currencies on the site completely, I tried in different ways and through jquery, including ...
Site on Bitrix. There is a selector in the header, in the template. We send POST to the output and in cookies, there are no problems here, we remember everything as it should be.
$select = array('RUB'=>'','USD'=>'');
if(isset($_POST['select'])) {
setcookie("BX_CURRENCY",$_POST['select'], strtotime( '+30 days' ), SITE_DIR);
$select[$_POST['select']] = 'selected';
} elseif(isset($_COOKIE["BX_CURRENCY"])) {
$select[$_COOKIE["BX_CURRENCY"]] = 'selected';
}
?>
<form method="post">
<select class="form-control form-control-sm d-sm-none d-md-block" name="select" onchange="this.form.submit()">
<option value="RUB" <?=$select['RUB']?>>RUB</option>
<option value="USD" <?=$select['USD']?>>USD</option>
</select>
</form>
if ($_POST['select']=="RUB") {
echo $arItem["PRICES"]["Base"]["PRINT_VALUE"];
}elseif ($_POST['select']=="USD") {
echo "$ ".round(CCurrencyRates::ConvertCurrency($val, "RUB", "USD"), 2);
if ($_POST['select']=="") {
echo $arItem["PRICES"]["Base"]["PRINT_VALUE"];
}
Answer the question
In order to leave comments, you need to log in
select count(*) from (select distinct w.id from words w join test t on t.word_id_1=w.id) ww ;
Use kernel methods to work with cookies
https://dev.1c-bitrix.ru/api_d7/bitrix/main/web/co...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question