guys I have the following conflict:
I have the following code line in a form:
<div class="form-group">
<label for="monto">Seleccione Monto</label>
<select class="custom-select" id="monto_mensualidad" name="monto_mensualidad" value="';
echo $monto_mensualidad;
echo '" required >
<option value="">Seleccione:</option>';
monto_mensualidad();
echo '</select> <div class="invalid-feedback">Debe Seleccionar el monto de su transferencia.</div>
</div>
The function monto_mensualidad()
is the following, in this function the amount stored in the Database is selected as well as the name of the plan to which said plan corresponds, that is to say a plan of value 200 the plan is basic and the plan of value 500 the plan is Advanced and thus as it is shown to the user who sees the select:
function monto_mensualidad(){
global $db;
$query = "SELECT * FROM monto_mensualidad ORDER BY monto";
$results = mysqli_query($db, $query);
while ($valores_mensualidad = mysqli_fetch_array($results)) {
echo '<option value="'.$valores_mensualidad[monto].'">'.$valores_mensualidad[monto].' BsS Plan '.$valores_mensualidad[afiliacion] .'</option>';
}
}
On the other hand, inside the function generar_pago_mensualidad()
, where the information is stored in my database, I have the following:
function generar_pago_mensualidad(){
global $db, $username, $usua, $mes_de_pago_actual;
// Datos recibidos del Formulario
$monto = $_POST['monto_mensualidad'];
$banco_emisor = $_POST['banco_emisor'];
$banco_destino = $_POST['banco_destino'];
$nro_transf = $_POST['nro_transf'];
$ci_nro_cuenta = $_POST['ci_nro_cuenta'];
$fecha_transf = $_POST['fecha_transf'];
$ci_nro_cuenta = $_POST['ci_nro_cuenta'];
$status_pedido ="PENDIENTE";
$concepto = "MENSUALIDAD";
$verf = "SELECT nro_transf FROM pagos WHERE usuario = '$usua' AND nro_transf = '$nro_transf'";
$result = mysqli_query($db, $verf);
$rows = mysqli_num_rows($result);
if ($rows>0){
$_SESSION['success'] = "Lo sentimos, el numero de transferencia ya existe.<br>";
//mysqli_close($db);
} else {
$query = "INSERT INTO pagos (id, user, monto, concepto, mes_de_pago, afiliacion, banco_origen, banco_destino, nro_transf, ci_nro_cuenta, fecha_transf, status_pedido)
VALUES(null, '$user', '$monto', '$concepto', '$mes_de_pago_actual', '$afiliacion', '$banco_emisor', '$banco_destino', '$nro_transf', '$ci_nro_cuenta', '$fecha_transf', '$status_pedido')";
mysqli_query($db, $query);
$resultado_ingreso = mysqli_query($db, $query) or mysqli_error($db);
$_SESSION['success'] = "Se ha registrado su pedido de manera Exitosa.<br>";
//header('location: pedidos.php');
$email = $_SESSION['user']['email'];
$nombre = $_SESSION['user']['nombre'];
$asunto = "ASUNTO";
$cuerpo = "Hola $nombre: <br/><br/>
Usted ha registrado Pago del mes $mes_de_pago_actual de manera exitosa por un monto de $monto BsS <br>
Desde $banco_emisor hacia $banco_destino <br>
Numero de operacion $nro_transf <br>
Efectuado el $fecha_transf. <br/>";
enviarEmail($email, $nombre, $asunto, $cuerpo);
$_SESSION['success'] .= "Hemos enviado Un correo con el resumen de su pedido";
//header('location: pedidos.php');
//header('Refresh: 10; URL=pedidos.php');
}
}
My question is how can I get my function to recognize the value of my variable $afiliacion
as it does in function monto_mensualidad()
that is to say that if the person in the select selects 200 Bs Basic Plan then in the function generate_payment_month ( ) the value of my variable $monto = $_POST['monto_mensualidad'];
is 200 and the value of my variable $ affiliation is BASIC.