<?php include("conn_cadastro_enviar.php");
//Buscando se o usuário já existe
$busca_user="select * from assistidos where id = '".$_GET['id']."';";
$res_busca_user=mysql_query($busca_user,$conexao);
$campo_user=mysql_fetch_array($res_busca_user);
//Campos
$v_nome = $campo_user['nome'];
$v_sexo = $campo_user['sexo'];
$v_datadenascimento = $campo_user['datadenascimento'];
$v_telefone = $campo_user['telefone'];
$v_endereco = $campo_user['endereco'];
$v_bairro = $campo_user['bairro'];
$v_efermidade = $campo_user['efermidade'];
$v_progresso = $campo_user['progresso'];
$v_foto = $campo_user["foto"];
// Se a foto estiver sido selecionada
if (!empty($foto["name"])) {
/* // Largura máxima em pixels
$largura = 80;
// Altura máxima em pixels
$altura = 80;
// Tamanho máximo do arquivo em bytes
$tamanho = 100000; */
// Verifica se o arquivo é uma imagem
if(!eregi("^image\/(pjpeg|jpeg|png|gif|bmp)$", $foto["type"])){
$error[1] = "Isso não é uma imagem.";
}
// Pega as dimensões da imagem
$dimensoes = getimagesize($foto["tmp_name"]);
{
// Pega extensão da imagem
preg_match("/\.(gif|bmp|png|jpg|jpeg){1}$/i", $foto["name"], $ext);
// Gera um nome único para a imagem
$nome_imagem = md5(uniqid(time())) . "." . $ext[1];
// Caminho de onde ficará a imagem
$caminho_imagem = "fotos/" . $nome_imagem;
// Faz o upload da imagem para seu respectivo caminho
move_uploaded_file($foto["tmp_name"], $caminho_imagem);
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Editando Crianças Assistidas do GACC/SE</title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<h1>Editando Crianças Assistidas do GACC/SE </h1>
<form id="formularioContato" name="formularioContato" method="post" enctype="multipart/form-data">
<label>
<input name="nome" type="text" class="classebox" id="nome" value="<?php if (!empty($v_nome)) echo $v_nome; ?>" width="300" />
</label>
<br />
<br />
<select name="sexo" size="1">
<option value="Homem" <?php if (!empty($v_sexo) && $v_sexo == 'homem') echo 'selected = "selected"'; ?>>Homem</option>
<option value="Mulher" <?php if (!empty($v_sexo) && $v_sexo == 'mulher') echo 'selected = "selected"'; ?>>Mulher</option>
</select>
<br />
<br />
<label>
<input name="datadenascimento" type="text" class="classebox" id="datadenascimento" value="<?php if (!empty($v_datadenascimento)) echo $v_datadenascimento; ?>" width="300" />
</label>
<br />
<br />
<label>
<input name="telefone" type="text" class="classebox-fone" id="telefone" width="300px" value="<?php if (!empty($v_telefone)) echo $v_telefone; ?> " />
</label>
<br />
<br />
<label>
<input name="endereco" type="text" class="classebox-fone" id="endereco" width="300" value="<?php if (!empty($v_endereco)) echo $v_endereco; ?>" />
</label>
<br />
<br />
<label>
<input name="bairro" type="text" class="classebox" id="bairro" value="<?php if (!empty($v_bairro)) echo $v_bairro; ?>" width="300" />
</label>
<br />
<br />
<label>
<input name="efermidade" type="text" class="classebox" id="efermidade" value="<?php if (!empty($v_efermidade)) echo $v_efermidade; ?> " width="300" />
</label>
<br />
<br />
<textarea name="progresso" cols="45" rows="6" class="classebox" id="progresso" type="text".><?php if (!empty($v_progresso)) echo $v_progresso; ?>
</textarea>
<br />
<br />
<label>
<input type="file" name="foto" value="<?php if (!empty($v_foto)) echo $v_foto; ?>" />
</label>
<br />
<br />
<label>
<input name="submit" type="image" value="Editar Perfil" src="image/editar.png" />
</label>
</form>
<?
$nome_antigo=$_POST['nome'];
$nome = $_POST ['nome'];
$sexo = $_POST['sexo'];
$datadenascimento = $_POST['datadenascimento'];
$telefone = $_POST['telefone'];
$endereco = $_POST['endereco'];
$bairro = $_POST['bairro'];
$efermidade = $_POST['efermidade'];
$progresso = $_POST['progresso'];
$foto = $_FILES["foto"];
if(($nome_antigo!=NULL)or($nome!=NULL)or($sexo!=NULL)or($datadenascimento!=NULL)or($telefone!=NULL)or($endereco!=NULL)or($bairro!=NULL)or($efermidade!=NULL)or($progresso!=NULL)or($foto!=NULL))
{
/*
//Vendo se o nome já existe
$busca_usern="select * from assistidos where nome = '".$nome."';";
$res_busca_usern=mysql_query($busca_usern,$conexao);
$campo_usern=mysql_fetch_array($res_busca_usern);
if($campo_usern['nome']==NULL)
{
*/
$editar_doadores="UPDATE into assistidos (nome, sexo, datadenascimento, endereco, bairro, telefone, efermidade, progresso,foto )" . "VALUES ('".$nome."', '".$sexo."','".$datadenascimento."','".$endereco."','".$bairro."','".$telefone."','".$efermidade."','".$progresso."','".$nome_imagem."')";
$ok=mysql_query($editar_doadores,$conexao);
echo "<script>window.location='index.php?acao=cadastro';</script>";
}
//Caso tenha o usuário cadastrado
/*
else {
echo "<script>window.location='cadastrar_assistidos.php?acao=existe';</script>";
}
}
*/
?>
</body>
</html>
Me ajudem por favor ..



Postagens
Male
