write files to the database with ajax + jquery

0

I am not able to save data in the mysql database with ajax, can anyone help? Not from error or anything, just does not save. PHP:     

$serve = mysql_connect('localhost', 'root', '');
if(!$serve){ echo 'erro';}
$db = mysql_select_db('observatoriogaia', $serve);

if($_GET['acao']=='btnCadCadastra'){

 $nome = $_GET['nome'];
 $email = $_GET['email'];
 $senha = $_GET['senha'];

$SQL = "INSERT INTO usuarios (nome, email, senha)
VALUES ('$nome','$email','$senha')";

$re = mysql_query($SQL, $serve);
}

JavaScript:

var $server;
    $server = 'http://localhost/';

$(document).on("click", "#btnCadCadastra", function(evt)
{
        $nome = $('#idNome').val();
        $email = $('#idEmail').val();
        $senha = $('#idSenha').val();
                    $.ajax({
                        type: "get",
                        url: $server+"/conecta.php",
                        data: "nome="+$nome+"&acao=btnCadCadastra",
                        data: "email="+$email+"&acao=btnCadCadastra",
                        data: "senha="+$senha+"&acao=btnCadCadastra",
                        success: function(data) {
                            intel.xdk.notification.alert('Usuário cadastrado'); 
                        }
                    });
});

HTML:

<div class="upage-content ac0 content-area vertical-col left" id="page_72_85">
                <div class="table-thing with-label widget uib_w_8 d-margins" data-uib="jquery_mobile/input" data-ver="0">
                    <label class="narrow-control label-top-left" for="idNome">Nome de Usuário</label>
                    <input class="wide-control" placeholder="Ex: Gabriel" type="text" id="idNome" name="nome">
                </div>
                <div class="table-thing with-label widget uib_w_9 d-margins" data-uib="jquery_mobile/input" data-ver="0">
                    <label class="narrow-control label-top-left" for="idEmail">Email:</label>
                    <input class="wide-control" placeholder="seuemail@..." type="email" id="idEmail" name="email">
                </div>
                <div class="table-thing with-label widget uib_w_10 d-margins" data-uib="jquery_mobile/input" data-ver="0">
                    <label class="narrow-control label-top-left" for="idSenha">Senha</label>
                    <input class="wide-control" placeholder="**********" type="password" id="idSenha">
                </div>
                <div data-role="controlgroup" class="uib-jqm-flex widget uib_w_11 d-margins" data-uib="jquery_mobile/button_group" data-ver="0" data-type="horizontal">
                    <a class="widget uib_w_12" data-uib="jquery_mobile/button" data-ver="0" data-role="button" data-icon="delete" data-mini="true" id="btnCadCancela">Cancelar</a><a class="widget uib_w_14" data-uib="jquery_mobile/button" data-ver="0"
                    data-role="button" data-mini="true" data-icon="check" id="btnCadCadastra">Cadastrar</a>
                </div>
            </div>
    
asked by anonymous 03.10.2015 / 20:41

1 answer

1

I think you're formatting this data in the wrong way. Use it like this:

data: {
    acao: 'btnCadCadastra',
    nome: $nome,
    email: $email,
    senha: $senha
},

    
03.10.2015 / 20:50