I use the Paypal IPN. When the user buys articles, I use this code to generate codes they can redeem. However, it's not working:
public function clave(){
$Valores = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
$ValorTemporal = "";
for($i=0;$i<10;$i++) {
$ValorTemporal .= substr($Valores,rand(0,37),1);
}
return $ValorTemporal;
}
public function cupon($items){
$mysqli = $this->connection();
for ($i = 1; $i <= $items; $i++) {
$yz= $this->clave();
$sqli.$i = $mysqli->query("INSERT INTO ventas (id_venta, id_usuario,id_producto ,used,cupon) VALUES ('$txn_id','$username','$item_name','$used','$yz')");
}
return true;
}
$items is the number of products
I don't know if I'm using the for() statement correctly.
$sqli.$ialso$txn_id$username$item_name$usedare undefined in youcuponfunction