Button to delete events FullCalendar - Celke

0

In the code below, when I click on "Delete event" it gives an error that you need to select event (event ID).

Codewhereeventsareloaded:

eventClick:function(event){$('#visualizar#id').text(event.id);$('#visualizar#id').val(event.id);$('#visualizar#title').text(event.title);$('#visualizar#title').val(event.title);$('#visualizar#start').text(event.start.format('DD/MM/YYYYHH:mm:ss'));$('#visualizar#start').val(event.start.format('DD/MM/YYYYHH:mm:ss'));$('#visualizar#end').text(event.end.format('DD/MM/YYYYHH:mm:ss'));$('#visualizar#end').val(event.end.format('DD/MM/YYYYHH:mm:ss'));$('#visualizar#color').val(event.color);$('#visualizar').modal('show');returnfalse;},

Button:

<aclass="btn btn-danger" type="button" href="deletar_evento.php">Excluir evento</a>

deletar_evento.php:

<?php
session_start();
include_once("conexao.php");
$id = filter_input(INPUT_GET, 'id', FILTER_SANITIZE_NUMBER_INT);
if(!empty($id)){
    $result_events = "DELETE FROM events WHERE id='$id'";
    $resultado_events = mysqli_query($conn, $result_usuario);
    if(mysqli_affected_rows($conn)){
        $_SESSION['msg'] = "<div class='alert alert-success' role='alert'>Evento excluído com sucesso!<button type='button' class='close' data-dismiss='alert' aria-label='Close'><span aria-hidden='true'>&times;</span></button></div>";
        header("Location: index.php");
    }else{

        $_SESSION['msg'] = "<div class='alert alert-danger' role='alert'>Erro ao excluír evento!<button type='button' class='close' data-dismiss='alert' aria-label='Close'><span aria-hidden='true'>&times;</span></button></div>";
        header("Location: index.php");
    }
}else{  
    $_SESSION['msg'] = "<div class='alert alert-danger' role='alert'>É necessário selecionar um evento!<button type='button' class='close' data-dismiss='alert' aria-label='Close'><span aria-hidden='true'>&times;</span></button></div>";
    header("Location: index.php");
}

Celke's website: link

    
asked by anonymous 11.04.2018 / 14:44

2 answers

1

I think you need to put the dots for it to join the string with the variable:

Of this:

$result_events = "DELETE FROM events WHERE id='$id'";

For this:

$result_events = "DELETE FROM events WHERE id='".$id."'";

If you do not post the error please ...

    
11.04.2018 / 15:02
0

If you're familiar with Jquery, I'm not sure how you have the code, but you can try it out

The <a> tag should have a id , type like: <a href="deletar_inscricao.php" id="tag_a_alterar">

$('#calendar').fullCalendar({
  eventClick: function(event) {
     $("#tag_a_alterar").attr("href", "deletar_inscricao.php?id="+calEvent.id);
  }
});
                                    
12.04.2018 / 20:22