If I leave the code just below the inside of the funcoes.php
file of my system, when the page reloads, it deletes the post that I had deleted.
$tipo = $_GET['tipo'];
$funcao = $_GET['funcao'];
if($_GET['tipo'] == 'blog' && $_GET['funcao'] == 'excluir'){
require("classes/Database.php");
$pdo = Database::connect();
$pdo->query("DELETE FROM tb_blog WHERE ID = ".$_GET['id']."");
echo "
<META HTTP-EQUIV=REFRESH CONTENT = '0;URL='>
<script type=\"text/javascript\">
window.location = \"index\";
</script>
";
}
Now if I put this code inside a function
, it does not work.
function excluirDados(){
$tipo = $_GET['tipo'];
$funcao = $_GET['funcao'];
if($_GET['tipo'] == 'blog' && $_GET['funcao'] == 'excluir'){
require("classes/Database.php");
$pdo = Database::connect();
$pdo->query("DELETE FROM tb_blog WHERE ID = ".$_GET['id']."");
echo "
<META HTTP-EQUIV=REFRESH CONTENT = '0;URL='>
<script type=\"text/javascript\">
window.location = \"index\";
</script>
";
}
}
Question : Why the same code but inside a function does not work the same as the loose code inside the file?
I'm passing this url: .../index&tipo=blog&funcao=excluir&id=40