Excluindo Com e Sem PDO
Bom dia! Estou tentando fazer uma página de exclusão utilizando PDO (também tentei fazer sem), bom o problema é o seguinte quando clico no botão excluir de determinado cliente, atribuo esse nome para uma variável $nome através da variável global $_GET, mas a página simplesmente atualiza para a página inicial e não exclui o registro no banco. Abaixo estou enviando o código da página de exclusão, a função e também o SQL, se alguem puder me ajudar:D.... -------------- Código da página de exclusão
<?php
require_once 'funcoes/carregar.php'. $includes = array("paginas/", "funcoes/", "estilos/", "includes/", "email/", "phpmailer/"). try {
CarregaIncludes($includes). if(isset($_GET['nome'])): if($_GET['ac']=='del'): $nome=$_GET['nome']. if(deletarCli($nome)): echo "Cliente excluido com sucesso". else: throw new Exception('Erro ao excluir o cliente'). endif. else: throw new Exception ('É necessário selecionar um cliente'). endif. endif. } catch (Exception $e) {
echo "Erro ". $e->getMessage(). exit. }?>
<html xmlns="[http://www.w3.org/1999/xhtml](http://www.w3.org/1999/xhtml)"> <head> <link type="text/css" href="CSS/estilos/listagempro.css" rel="stylesheet" /> <meta http-equiv="Content-Type" content="text/html. charset=utf-8" /> <title>Painel de Controle</title> </head> <body> <div id="geralcad"> <div id="lateralescad"> </div> <div id="listagem"> <br />
<?php
$dados = listarCli(). $d = new ArrayIterator($dados).?> <ul>
<?php while($d->valid()):?> <li><?php echo $d->current()->nome.?></li> <li><a href="?nome=<?php echo $d->current()->nome.?>&ac=del">Excluir</a></li>
<?php
$d -> next(). endwhile.?>
</ul>
</div> </div> </body>
</html> ----- Função function deletarCli($nome){ $pdo= conectarBanco(). try{ $deletar= $pdo->prepare("DELETE FROM clientes WHERE nome=:nome"). $deletar->bindValue(":nome",$nome,PDO::PARAM_STR). $deletar->execute(). if($deletar->rowCount()==1): return true. else: return false. endif. }catch(PDOException$e){ echo "Erro". $e->getMessage(). }
} ----- SQL /*SQLyog Ultimate v11.11 (64 bit)
MySQL - 5.5.8-log
*********************************************************************
*/
/*!40101 SET NAMES utf8 */. create table `clientes` ( `˜ãÐ` text, `ØãÐ` text, `(äÐ` text, `xäÐ` text, `¸äÐ` text, `øäÐ` text, `HåÐ` text
). insert into `clientes` (`nome`, `nascimento`, `endereco`, `cidade`, `email`, `telefone`, `celular`) values('teste1','18-11-1989','teste1','teste1','teste1','teste1','teste1'). insert into `clientes` (`nome`, `nascimento`, `endereco`, `cidade`, `email`, `telefone`, `celular`) values('teste2','18-12-1989','teste2','teste2','teste2','teste2','teste2'). insert into `clientes` (`nome`, `nascimento`, `endereco`, `cidade`, `email`, `telefone`, `celular`) values('teste3','18-11-1989','teste3','teste3','teste3','teste3','teste3'). insert into `clientes` (`nome`, `nascimento`, `endereco`, `cidade`, `email`, `telefone`, `celular`) values('teste4','21-10-1989','teste4','teste4','teste4','teste4','teste4'). Desde já agradeço a atenção de todos.Discussão (9)
Carregando comentários...