I have the following function which receives an id as parameter:
function terminar_tramite(ids) {
var ID = ids;
console.log(ID);
$.ajax({
url: "lib/controladores/tramite_terminado.php",
type: 'POST',
data: 'idss=${ID}',
contentType: false,
processData: false,
success: function(response){
if (response.success) {
console.log("no está guardando")
UIkit.notification({
message: 'Ocurrió un error!',
status: 'primary',
pos: 'top-right',
timeout: 5000
});
}else{
UIkit.notification({
message: 'Tramite Guardado!',
status: 'success',
pos: 'bottom-center',
timeout: 5000
});
setTimeout(function(){
location.href = '?sub=adm&op=tablero_tramites';
},2000);
setTimeout(function(){
location.href = '?sub=adm&op=tablero_tramites';
},2000);
}
}
})
}
My PHP code:
<?php
include '../../config.php';
$dbserver = DB_SERVER;
$dbuser = DB_USER;
$password = DB_PASS;
$dbname = DB_NAME;
$database = new mysqli($dbserver, $dbuser, $password, $dbname);
$variable = $_POST['idss'];
var_dump($variable);
if($database->connect_errno) {
die("No se pudo conectar a la base de datos");
}
$insertquery = " INSERT INTO tramites_atendidos SELECT * FROM tramites WHERE tr_id = '$variable'";
$jsondata = array();
if($database->query($insertquery)){
}
else {
}
$database->close();
?>
I just do not get the id or I would not know if I'm adding it correctly in my Query because if I put the id directly if it copies the record