ok i have now sorted the encoding out i have not included the BOM and i have also changed the £ sign for the letter "p" and the % sign for "c" this way its no special characters just letters and numbers.
i have also changed the Database values to read
lot123p5 ( this is £5 off )
or
lot123f10 ( this 10% off )
and the php code to match this
Code: Select all
// voucher code
if (isset($_POST['vouchCode']) && $_POST['vouchCode'] == $row_rsVoucher['VCode']) {
$mycode = $row_rsVoucher['VCode'];
$spos = strpos($mycode, "f");
if ($spos !== false) {
$myvalue = substr($mycode, $spos+1);
$myvalue = $XCart_sumTotal * $myvalue / 100;
} else {
$spos = strpos($mycode, "p");
if ($spos !== false) {
$myvalue = substr($mycode, $spos+1);
}
}
$myTotal = $XCart_sumTotal - $myvalue;
$_SESSION['vouchCode'] = $myvalue;
} else unset($_SESSION['vouchCode']);
function DoFormatCurrency($num,$dec,$sdec,$sgrp,$sym,$cnt) {
setlocale(LC_MONETARY, $cnt);
if ($sdec == "C") {
$locale_info = localeconv();
$sdec = $locale_info["mon_decimal_point"];
$sgrp = $sgrp!="" ? $locale_info["mon_thousands_sep"] : "";
$sym = $cnt!="" ? $locale_info["currency_symbol"] : $sym;
}
$thenum = $sym.number_format($num,$dec,$sdec,$sgrp);
return $thenum;
}
what is happening is i have echoed out
Code: Select all
<?php echo $myvalue ?><br />
<?php echo $_POST['vouchCode']; ?><br />
<?php echo $row_rsVoucher['VCode']; ?> <br />
the <?php echo $row_rsVoucher['VCode']; ?> is always showing the lot123p5 which is the first record on the DB
when i submit the value lot123p5 i get the following
<?php echo $myvalue ?> shows 5
<?php echo $_POST['vouchCode']; ?> shows lot123p5
and <?php echo $row_rsVoucher['VCode']; ?> shows lot123p5
so thats working
when i try the percentage and submit lot123f10 i get the following
<?php echo $myvalue ?> shows nothing
<?php echo $_POST['vouchCode']; ?> shows lot123f10
and <?php echo $row_rsVoucher['VCode']; ?> shows lot123p5
and therefor isnt working
i have added another discount code to the £ discount to see if it was the % thing
lottiep3
to show £3 discount but that isnt working either so it must only be working for the first record in the DB