Created
April 14, 2014 15:49
-
-
Save leocavalcante/10660004 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $imagem = $_FILES['imagem']; | |
| $logradouro = $_REQUEST['logradouro']; | |
| $preco = $_REQUEST['preco']; | |
| $modo = $_REQUEST['modo']; | |
| $excluir = $_REQUEST['excluir']; | |
| if($modo == "cadastro"){ | |
| $stmt = $db->prepare('insert into imoveis (logradouro, preco) values(?, ?)'); | |
| $stmt->bindValue(1, $logradouro); | |
| $stmt->bindValue(2, $preco); | |
| $stmt->execute(); | |
| if (!empty($imagem["name"])) { | |
| // Pega extensão da imagem | |
| preg_match("/\.(gif|bmp|png|jpg|jpeg){1}$/i", $imagem["name"], $ext); | |
| // Gera um nome único para a imagem | |
| $nome_imagem = md5(uniqid(time())) . "." . $ext[1]; | |
| // Caminho de onde ficará a imagem | |
| $caminho_imagem = "uploads/" . $nome_imagem; | |
| move_uploaded_file($imagem["tmp_name"], $caminho_imagem); | |
| } | |
| } | |
| if(!empty($excluir)){ | |
| $stmt = $db->prepare('delete from imoveis where id = ?'); | |
| $stmt->bindValue(1, $excluir); | |
| $stmt->execute(); | |
| $mensagem = "Cadastro excluido"; | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment