Problems Connecting Intel XDK Application to Database

Asked

Viewed 58 times

0

Good afternoon. I have the following problem: I created an application on intel xdk but I can not in any way send the user registration data to the database. I’m using the wampserver. I looked at a tutorial on the internet and in the tutorial the guy used the same tools as me, but mine just isn’t right. I don’t have much knowledge in php, I copied the tutorial class and modeled it according to my application, I also took the app.js class and did the same thing. There’s something wrong with them?

php class:

<?php
header("Access-Control-Allow-Origin: *");
header("Content-Type: Application/html; charset-UTF-8");

$nome = $_POST['nome'];
$nickname = $_POST['nickname'];
$curso = $_POST['curso'];
$semestre = $_POST['semestre'];
$ra = $_POST['ra'];
$senha = $_POST['senha'];


$db = new mysqli("localhost","root","","aluno");

$sql = "insert into aluno values(NULL,'".$nome."', '".$nickname."', '".$curso."', '".$semestre."', '".$ra."', '".$email."', '".$senha."')";

$db->query($sql);
$db->close;

?>

Javascript

(function(){


"use strict";

function event_handlers(){

  $(document).on("click", "#envia", function(e){
   e.preventDefault();

          var recupera =  $("form#cadastro").serialize();
          var recupera = "http://localhost/app/apicadastro.php"
              $.ajax({
                  type: "POST",
                  url: url,
                  data: recupera,
                  async: false

              }).done(function(){

                 navigator.notification.alert("Dados inseridos com sucesso", null, "Sucesso", "OK");

              }).fail(function(){

                navigator.notification.alert("Falha!", null, "Falha", "OK");

              });


  });


}

document.addEventListener("app.Ready", event_handlers, false);


})();
  • Hi. You’re rewriting the variable recupera with the URL, and thus you lack the definition of the URL variable.

  • Hi Foxtrot, I made the correction, thanks. But even so the data is not entered, there is something wrong with php?

  • 1

    @Romulofilho is not yet corrected here in the question, correct var recupera = $("form#cadastro").serialize(); is being overwritten right after var recupera = "http://localhost/app/apicadastro.php"

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.