Move row to another table in PHP PDO database

-1

I have a movie table on my site that you have the option to edit and delete. I'm having trouble deleting the movie from my table. What I want to do is: When you click Delete, it moves the row to another table of the same type, doing backup. After it moves, delete the row from the current table.

What I can not do is pass the field id on the link. When I click the button to "delete" the table, it does not pass the desired value, passing only the value 2.

Follow my code:

Boot

<a href="painel_adm_deletefilme.php?idFilme='.$dados['idFilme'].'"><input class="btn btn-danger" name="excluirFilme" value="Sim" class="btn btn-danger"></input></a>

panel_adm_deletefilme

<?php

session_start ();    include_once 'connectBanco.php';

$id = $_GET["idFilme"];

$envia = "INSERT INTO filmesDelet (idFilme, filme, descricao, genero, anoLancamento, faixaEtaria, trailer) 
SELECT idFilme, filme, descricao, genero, anoLancamento, faixaEtaria, trailer 
from filmes where idFilme = '$id'";

$insere_bd = $conecta->prepare($envia);

if($insere_bd->execute()){
    echo 'sucesso';
}else{
    echo 'failed';
}

? >

The code returns no error. It goes right into the success if, not being passed the table the desired line. Whenever I click to "delete" it passes the value id 2.

    
asked by anonymous 21.11.2018 / 01:54

2 answers

1

But why all this work? Is it really necessary to move to another table? Because you do not create a "excluded (bool)" column and mark it as true when the client exclose the record, then show only the non-excluded "where exluidos = false"

But if you really want to "copy and paste" keeping the same ID, you should first check if your bank ID is not auto increment and then just load the data and insert the backup table.

Vlw!

    
21.11.2018 / 02:07
0

This part of the code does not look right:

<a href="painel_adm_deletefilme.php?idFilme='.$dados['idFilme'].'">

You put php code straight into html. I think it would work if I traded for it:

<a href="painel_adm_deletefilme.php?idFilme=<?=$dados['idFilme'];?>">
    
21.11.2018 / 14:43