So what i want to make and what i have problems with!
The "all" is not showing if the user haven't selected a currency!
How to write the code so if the "all" is loaded it uses the code from the individual if's per currency
How to delete the the use of
<input type="submit" value="Select currency">
button so its automatic change when a Currency is selected
(inside the <body>
)
So how to delete the use of <input type="submit" value="Select currency">
button so its automatic change when a Currency is selected?
<form action="currency_switcher.php" method="post">
<select name="money">
<option value="all"<?php if( $_COOKIE["currency"] == "all" ) { echo " selected"; } ?>>All Currencies</option>
<option value="IDR"<?php if( $_COOKIE["currency"] == "IDR" ) { echo " selected"; } ?>>Indonesia RP</option>
<option value="AUD"<?php if( $_COOKIE["currency"] == "AUD" ) { echo " selected"; } ?>>Australian Dollars</option>
<option value="USD"<?php if( $_COOKIE["currency"] == "USD" ) { echo " selected"; } ?>>American Dollars</option>
<option value="SGD"<?php if( $_COOKIE["currency"] == "SGD" ) { echo " selected"; } ?>>Singapore Dollars</option>
</select>
<input type="submit" value="Select currency">
</form>
So the "all" is not showing if the user haven't selected a currency!
And how to write the code so the code from example IDR showing if ALL currency is loaded so i dont need to have the code two times written!.
<?php
if( $_COOKIE["currency"] == "all") {
echo "code";
echo "code IDR";
echo "code";
echo "code AUD";
echo "code";
echo "code USD";
echo "code";
echo "code SGD";
}
if ( $_COOKIE["currency"] == "IDR" ) {
echo "code IDR";
}
if ( $_COOKIE["currency"] == "AUD" ) {
echo "code AUD";
}
if ( $_COOKIE["currency"] == "USD" ) {
echo "code USD";
}
if ( $_COOKIE["currency"] == "SGD" ) {
echo "code SGD";
}
?>
The currency_switcher.php
<?
$money = "all";
if( isset( $_POST["money"] ) ) {
$money = $_POST["money"];
setcookie ( 'currency', $money, time() + 60*60*24*30, '/', 'exampledomain.com');
header('Location: ' . $_SERVER['HTTP_REFERER']);
exit;
}
?>
</div>