tengo esta funcion en javascript
function addRow( i , name , first , second , final , partic , abc , Grade){ names[i] = name; fiM[i] = first; secM[i] = second; finalM[i] = final; parti[i] = partic; Y_N[i] = ABC; grades[i] = Grade; }Quiero insertar los parámetros de esta función en una base de datos usando php Traté de resolver este problema usando ajax pero creo que no lo usé correctamente
Probé este código:
function addRow( i , name , first , second , final , partic , abc , Grade){ computeBtn.addEventListener("click", (e) => { let xmlhttp = new XMLHttpRequest(); xmlhttp.open( "GET", "addStudent.php?first=" + first+ "&second=" + second + "&final=" + final + "&prt=" + partic+ "&abc = " + abc + "&name = " + name+ "&grade = " +grade , true ); xmlhttp.send(); xmlhttp.onstatechange = function () { console.log(xmlhttp.response); }; }); names[i] = name ; fiM[i] = first ; secM[i] = second ; finalM[i] = final ; parti[i] = partic ; Y_N[i] = abc ; grades[i] = Grade ; }y en archivo php
<?php $con = mysqli_connect("localhost", "root","12345678", "advanceweb"); $name = $_GET['name']; $first = $_GET['first']; $second = $_GET['second']; $final = $_GET['final']; $prt = $_GET['prt']; $abs = $_GET['abc']; $g = $_GET['grade']; $q_insert = "INSERT INTO `newstudent` (`StudentName`, `first`, `second`, `final`, `partcipation`, `Absences`, `grade`) VALUES ('$name','$first','$second','$final','$prt','$abs','$g')"; mysqli_query($con, $q_insert); mysqli_close($con);?>¿Alguien puede ayudarme a corregirlo por favor?