forked from alvesil/projetofinaletc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathatualizarPet.php
41 lines (36 loc) · 1.05 KB
/
atualizarPet.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php require_once("app/UsuarioDAO.php"); ?>
<?php require_once("app/Usuarios.php"); ?>
<?php
$id = $_POST['id'];
$nome = $_POST['nome'];
$sexo = $_POST['sexo'];
$peso = $_POST['peso'];
$nasc = $_POST['nasc'];
$foto = $_FILES['foto']['name'];
echo $id;
echo $nome;
echo $sexo;
echo $peso;
echo $nasc;
echo $foto;
$target_dir = "uploads/pets/";
$target_file = $target_dir . basename($_FILES["foto"]["name"]);
$uploadOk = 1;
$imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
if (move_uploaded_file($_FILES["foto"]["tmp_name"], $target_file)) {
echo "The file ". htmlspecialchars( basename( $_FILES["foto"]["name"])). " has been uploaded.";
}
$novoPet = new Pet;
$novoPet->setPetID($id);
$novoPet->setPetNome($nome);
$novoPet->setPetSexo($sexo);
$novoPet->setPetPeso($peso);
$novoPet->setPetDataNascimento($nasc);
$novoPet->setPetFoto($foto);
$atualizarPet = new ClassUsuarioDAO;
$resultado = $atualizarPet->atualizarPet($novoPet);
if ($resultado == true) {
// code...
header("Location: index.php?petUpdated=true");
}
?>