I have an HTML form with method="POST" and a submit button. Within my file 'purchases.controller.php', if I do a var_dump ($ _ POST), you can see all my POST variables belonging to the inputs of the form correctly.
Now, I have another file called 'aux.php' which gets an array through AJAX and then I pass it to a function of a class in the file 'purchases.controller.php'. There, I want to manipulate the array and the POST variables that are arriving, but it only allows me to manipulate the array, the POST within the function do not exist.
Does anyone know what I'm doing wrong?
I share the purchase code.controller.php:
//ACÁ ME MUESTRA LAS VARIABLES POST COMO EL 'registroUsuario', ETC.
var_dump($_POST)
class Compras {
public function ctrEfectivo(&$arrayCompleto){
//ACÁ SE MUESTRA EL ARRAY CORRECTAMENTE
var_dump("Muestro mi array dentro de la clase y función: ", $arrayCompleto);
if(isset($_POST["registroUsuario"])){
if(preg_match('/^[a-zA-ZñÑáéíóúÁÉÍÓÚ ]+$/', $_POST["registroUsuario"]) &&
preg_match('/^([0-2][0-9]|3[0-1])(\/|-)(0[1-9]|1[0-2])(\d{4})$/', $_POST["registroCalendario"]) &&
preg_match('/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/', $_POST["registroEmail"]) &&
preg_match('/^(?:\D*\d){2,4}\D*$/', $_POST["registroDireccion"]) &&
preg_match('/^[0-9]{7,12}$/', $_POST["registroTelefono"])) {
//ACÁ QUIERO MANIPULAR TODO, PERO NO PUEDO YA QUE NO ESTÁN LLEGANDO LOS POST
}
And here is the aux.php file:
if(isset($_POST['arrayCompleto'])){
include ('compras.controlador.php');
$arrayCompleto = json_decode($_POST['arrayCompleto'], true);
$nuevaCompra = new Compras();
$nuevaCompra -> ctrEfectivo($arrayCompleto);
}
This is the HTML form:
<form method="post" onsubmit="return validacionForm()" id="formCash">
<input type="text" class="form-control" id="registroUsuario" name="registroUsuario" placeholder="Nombre Completo" maxlength="26" required>
<input type="text" class="form-control" id="registroDireccion" name="registroDireccion" placeholder="Dirección de envío con altura de calle" required>
<input type="text" class="form-control" id="registroCalendario" name="registroCalendario" placeholder="Día de envío" required>
<input type="email" class="form-control" id="registroEmail" name="registroEmail" placeholder="Correo Electrónico" maxlength="32" required>
<input type="text" class="form-control" id="registroTelefono" name="registroTelefono" placeholder="Teléfono de contacto" maxlength="16" onkeypress="return isNumber(event)" required>
<?php
$compra = new Compras();
$compra -> ctrEfectivo();
?>
<input type="submit" class="btn btn-block btn-lg btn-default backColor btnPagar" id="btnPagar" value="CONFIRMAR PEDIDO">
</form>