Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

161
Views
Insertar variables de JavaScript en la base de datos

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?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!