I am inserting data in a table called payments, the table stores payments that a student has made, the problem arises that when a student enrolls for the first time to process the first payment in the payment table, two rows are saved with all the empty fields and already in the 3rd row is that it saves the data well. but that only happens when it is the first payment of a new student, if I return to process another payment to that same student if he keeps the data well. In the form in which I send the data, some inputs are filled with a query. I will leave the function where I insert.
public function pago_cuota($id,$f_pay,$concepto,$monto,$forma,$bco,$refer)
{
$mysqli = new mysqli('localhost','root', '' , 'academia');
$estatus = "PAGADA";
$fecha_new = date('d-m-Y', strtotime("$f_pay + 1 month"));
$query = "INSERT INTO pagos(id_student,concepto,monto,forma_pago,banco,n_referencia,fecha_pago,estatus)
VALUES('$id','$concepto','$monto','$forma','$bco','$refer', '$fecha_new','$estatus')";
$sql = $mysqli->query($query);
}