Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Boa noite amigos mais uma vez recorro a ajuda de vocês seguinte tenho um sistema em meu site cuja acrescentei para trocar a foto do perfil do usuário mais não sei o porque esta fazendo tudo certinho mais não esta gravando no db não sei se o código que estou usando esta errado teria como alguém verificar para mim. abaixo as paginas
meusdados.php e onde aparece a foto mais só fica o espaço em branco não sei o que é
>
<?php
require_once("config.php");
loadClass("protege");
$protege=new protege();
require_once("topo.php");
if(!logado()){
alertaredir("Você precisa estar logado para acessar essa área do site","inicio");
exit;
}
if($_SERVER['REQUEST_METHOD']==='POST' && isset($_POST['act']) && $_POST['act']==='gravar'){
if(isset($_POST['token']) && $_POST['token']==$_SESSION['token']){
foreach($_POST as $k=>$v){
$post[$k]=$protege->geral($v);
}
extract($post);
loadClass("image");
$upl=new imagem();
$sizeimg=getConfig('tamanhoimg');
$upl->setAttr( ($sizeimg*1024) * 1024);
if(is_uploaded_file($_FILES['avatar']['tmp_name'])){
$arq=$upl->envio($_FILES['avatar'],"uploads/avatar");
if(!$arq){
alertaredir('Tipo de Arquivo inválido ou tamanho do upload excedido','meusdados');
exit;$sqluav=$db->query("select avatar from membros where id=".$_SESSION['loginu_id']);
$userav=$sqluav->fetch_object();
@unlink("uploads/avatar/".$userav->avatar);
$sql=$db->query("update membros set avatar='$arq' where id=".$_SESSION['loginu_id']);
}
}
$sql=$db->query("update membros setwhere id=".$_SESSION['loginu_id']);
if($sql){
alertaredir("Gravado com sucesso","meusdados");alertaredir("Falha ao gravar","meusdados");
}
}else{
alertaredir("Violação de Acesso","meusdados");
}
}
$sqlm=$db->query("select * from membros where id=".$_SESSION['loginu_id']);
$membro=$sqlm->fetch_array();
extract($membro);
?>
<div class="quadroprincipal">
<div>
<strong>Logado como: </strong><?php echo html_entity_decode($_SESSION['loginu_nome']);?> <a href="logout">(Sair)</a>
</div>
<h2 class="tituloquadro">Meus Dados</h2>
<?php require_once("menumc.php"); ?>
<div class="infomembro">
<form method="POST" action="meusdados" id="formmeusdados" enctype="multipart/form-data">
<input type="hidden" name="act" value="editar"/>
<input type="hidden" name="token" value="<?php echo $_SESSION['token'];?>"/>
<p>
<label>Nome</label><br/>
<input type="text" name="nome" id="nome" class="txt400" value="<?php echo html_entity_decode($nome);?>"/>
</p>
<p>
<label>Sobrenome</label><br/>
<input type="text" name="sobrenome" id="sobrenome" class="txt400" value="<?php echo html_entity_decode($sobrenome);?>"/>
</p>
<p>
<label>Avatar:</label><br/>
<input type="file" id="avatar" name="avatar"/><br/>
</p>
<p>
<div class="avatarlat">
<?php
$sqlavt=$db->query("select avatar from membros where id=".$_SESSION['loginu_id']);
$avt=$sqlavt->fetch_object();
if($avt!=''){ ?>
<img src="uploads/avatar/<?php echo html_entity_decode($avt->avatar);?>" width="90"/>
<?php }else{ ?>
<img src="lib/img/semfoto.gif" width="90"/>
<?php } ?>
</div>
</p>
<p>
<label>Cidade</label><br/>
<input type="text" name="cidade" id="cidade" class="txt400" value="<?php echo html_entity_decode($cidade);?>"/>
</p>
<p>
<label>Estado</label><br/>
<select name="uf" id="uf" class="txt200">
<option value="">Selecione</option>
<option value="AC" <?php if($uf=='AC') echo 'selected="selected"';?>>Acre</option>
<option value="AL" <?php if($uf=='AL') echo 'selected="selected"';?>>Alagoas</option>
<option value="AP" <?php if($uf=='AP') echo 'selected="selected"';?>>Amapá</option>
<option value="AM" <?php if($uf=='AM') echo 'selected="selected"';?>>Amazonas</option>
<option value="BA" <?php if($uf=='BA') echo 'selected="selected"';?>>Bahia</option>
<option value="CE" <?php if($uf=='CE') echo 'selected="selected"';?>>Ceará</option>
<option value="DF" <?php if($uf=='DF') echo 'selected="selected"';?>>Distrito Federal</option>
<option value="ES" <?php if($uf=='ES') echo 'selected="selected"';?>>Espirito Santo</option>
<option value="GO" <?php if($uf=='GO') echo 'selected="selected"';?>>Goiás</option>
<option value="MA" <?php if($uf=='MA') echo 'selected="selected"';?>>Maranhão</option>
<option value="MT" <?php if($uf=='MT') echo 'selected="selected"';?>>Mato Grosso</option>
<option value="MS" <?php if($uf=='MS') echo 'selected="selected"';?>>Mato Grosso do Sul</option>
<option value="MG" <?php if($uf=='MG') echo 'selected="selected"';?>>Minas Gerais</option>
<option value="PA" <?php if($uf=='PA') echo 'selected="selected"';?>>Pará</option>
<option value="PB" <?php if($uf=='PB') echo 'selected="selected"';?>>Paraíba</option>
<option value="PR" <?php if($uf=='PR') echo 'selected="selected"';?>>Paraná</option>
<option value="PE" <?php if($uf=='PE') echo 'selected="selected"';?>>Pernambuco</option>
<option value="PI" <?php if($uf=='PI') echo 'selected="selected"';?>>Piauí</option>
<option value="RJ" <?php if($uf=='RJ') echo 'selected="selected"';?>>Rio de Janeiro</option>
<option value="RN" <?php if($uf=='RN') echo 'selected="selected"';?>>Rio Grande do Norte</option>
<option value="RS" <?php if($uf=='RS') echo 'selected="selected"';?>>Rio Grande do Sul</option>
<option value="RO" <?php if($uf=='RO') echo 'selected="selected"';?>>Rondônia</option>
<option value="RR" <?php if($uf=='RR') echo 'selected="selected"';?>>Rorâima</option>
<option value="SS" <?php if($uf=='SS') echo 'selected="selected"';?>>Santa Catarina</option>
<option value="SP" <?php if($uf=='SP') echo 'selected="selected"';?>>São Paulo</option>
<option value="SE" <?php if($uf=='SE') echo 'selected="selected"';?>>Sergipe</option>
<option value="TO" <?php if($uf=='TO') echo 'selected="selected"';?>>Tocantins</option>
</select>
</p>
<p>
<label>Receber Mensagens internas</label><br/>
<select name="recebermsg" id="recebermsg" class="txt200">
<option value="">Selecione</option>
<option value="site" <?php if($recebermsg=='site') echo 'selected="selected"';?>>Site</option>
<option value="email" <?php if($recebermsg=='email') echo 'selected="selected"';?>>E-mail</option>
</select>
</p>
<p>
<label>E-mail</label><br/>
<input type="text" name="email" id="email" class="txt400" value="<?php echo html_entity_decode($email);?>"/>
</p>
<p>
<label>Senha</label><br/>
<input type="password" autocomplete="off" name="senha" id="senha" class="txt200" value="<?php echo html_entity_decode($senha);?>"/>
</p>
<p>
<label>Dados Bancários:</label><br/>
<span class="orient">
<strong>Incluir todos os dados necessários como segue:</strong> <br>
Nome do Titular da conta, Nome do Banco, Número do banco(caso seja necessário),<br></span><br/>
<textarea name="banco" id="banco" class="txt400" rows="10"><?php echo html_entity_decode($banco);?></textarea>
</p>
<p>
<input type="submit" value="Gravar" class="submit_gravar"/>
</p>
</form>
</div>
</div>
<?php require_once("rodape.php"); ?>
config.php
>
<?php
session_start();
header('Content-Type: text/html; charset=utf-8');
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: private, no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
setlocale(LC_ALL,"pt_BR");
date_default_timezone_set("Brazil/East");
require_once("config-init.php");
function loadClass($nome){
if(file_exists("class/$nome.class.php")){
require_once("class/$nome.class.php");
}else{
exit("Classe não encontrada: $nome");
}
}
loadClass("database");
$db=new database($db_host,$db_nome,$db_user,$db_pwd);
function dataBrasil($data){
$dt1=explode(" ",$data);
$dt=explode("-",$dt1[0]);
if(count($dt1)>1){
$hrs=" ".$dt1[1];
}else{
$hrs="";
}
$data=$dt[2]."/".$dt[1]."/".$dt[0].$hrs;
return $data;
}
function dataMysql($data){
$dt1=explode(" ",$data);
$dt=explode("/",$dt1[0]);
if(count($dt1)>1){
$hrs=" ".$dt1[1];
}else{
$hrs="";
}
$data=$dt[2]."-".$dt[1]."-".$dt[0].$hrs;
return $data;
}
function alerta($msg){
$src= '<script type="text/javascript">';
$src.='alert("'.$msg.'");';
$src.='</script>';
echo $src;
}
function alertaredir($msg,$local){
$src= '<script type="text/javascript">';
$src.='alert("'.$msg.'");';
$src.='window.location="'.$local.'";';
$src.='</script>';
echo $src;
}
function redir($local){
$src= '<script type="text/javascript">';
$src.='window.location="'.$local.'";';
$src.='</script>';
echo $src;
}
function goback(){
$src= '<script type="text/javascript">';
$src.='window.history.back();';
$src.='</script>';
echo $src;
}
function isValidID($id,$tabela,$query=''){
global $db;
$where='';
if($query!=''){
$where=" AND $query";
}
$sql=$db->query("select * from $tabela where id=$id $where");
if($sql->num_rows>0){
return true;
}else{
return false;
}
}
function emailcad($email){
global $db;
$sql=$db->query("select * from membros where email='$email'");
if($sql->num_rows>0){
return true;
}else{
return false;
}
}
function emailcadU($email){
global $db;
$sql=$db->query("select * from membros where email='$email' AND id<>".$_SESSION['loginu_id']);
if($sql->num_rows>0){
return true;
}else{
return false;
}
}
function usercad($user){
global $db;
$sql=$db->query("select * from usuarios where nomeusuario='$user'");
if($sql->num_rows>0){
return true;
}else{
return false;
}
}
function usercadU($user){
global $db;
$sql=$db->query("select * from usuarios where nomeusuario='$user' AND id<>".$_SESSION['loginu_id']);
if($sql->num_rows>0){
return true;
}else{
return false;
}
}
if(!isset($_SESSION['token'])){
$_SESSION['token']=md5(date("d-m-Y H:i:s"));
}
function login($user,$senha){
if($user!='' && $senha!=''){
global $db;
$sql=$db->query("select * from membros where email='$user' and senha='$senha' and status='ATIVO'");
if($sql->num_rows>0){
$usuario=$sql->fetch_object();
$_SESSION['loginu']='ok';
$_SESSION['loginu_id']=$usuario->id;
$_SESSION['loginu_nome']=$usuario->nome." ".$usuario->sobrenome;
$_SESSION['loginu_email']=$usuario->email;
$_SESSION['loginu_avatar']=$usuario->avatar;
return true;
}else{
return false;
}
}else{
return false;
}
}
//ver se cliente esta logado
function logado(){
if(isset($_SESSION['loginu']) && $_SESSION['loginu']=='ok'){
return true;return false;
}
}
function logout(){
unset($_SESSION['loginu']);
unset($_SESSION['loginu_id']);
unset($_SESSION['loginu_nome']);
unset($_SESSION['loginu_email']);
unset($_SESSION['loginu_avatar']);
}
function reais($valor,$pref=''){
return $pref.number_format($valor,2,',','.');
}
function addTime($valor1,$valor2){
$t1=explode(":",$valor1);
$t2=explode(":",$valor2);
$tempo=date("H:i:s",mktime($t1[0]+$t2[0],$t1[1]+$t2[1],$t1[2]+$t2[2],0,0,0));
return $tempo;
}
function subTime($valor1,$valor2){
$t1=explode(":",$valor1);
$t2=explode(":",$valor2);
$tempo=date("H:i:s",mktime($t1[0]-$t2[0],$t1[1]-$t2[1],$t1[2]-$t2[2],0,0,0));
return $tempo;
}
function addDate($valor1,$dias){
$t1=explode("-",$valor1);
$tempo=date("Y-m-d",mktime(0,0,0,$t1[1],$t1[2]+$dias,$t1[0]));
return $tempo;
}
function subDate($valor1,$dias){
$t1=explode("-",$valor1);
$tempo=date("Y-m-d",mktime(0,0,0,$t1[1],$t1[2]-$dias,$t1[0]));
return $tempo;
}
function getConfig($nome){
global $db;
$sql=$db->query("select $nome from configuracoes");
$config=$sql->fetch_assoc();
return html_entity_decode($config[$nome]);
}
function getTexto($id){
global $db;
$sql=$db->query("select texto from textos where id=$id");
$tx=$sql->fetch_assoc();
return html_entity_decode($tx['texto']);
}
?>
imagem.class.php
>
<?php
class imagem{
public $tamanho=2097152;
public function setAttr($tamanho){
$this->tamanho=$tamanho;
}
public function geraThumb($photo, $output, $new_width){$source = imagecreatefromstring(file_get_contents($photo));
list($width, $height) = getimagesize($photo);
if ($width>$new_width){
$new_height = ($new_width/$width) * $height;
$thumb = imagecreatetruecolor($new_width, $new_height);
imagecopyresampled($thumb, $source, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
imagejpeg($thumb, $output, 100);copy($photo, $output);
}
return true;return false;
}
}
public function geraThumbdef($photo, $output, $new_width, $new_height){$source = imagecreatefromstring(file_get_contents($photo));
list($width, $height) = getimagesize($photo);
if ($width>$new_width){
$thumb = imagecreatetruecolor($new_width, $new_height);
imagecopyresampled($thumb, $source, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
imagejpeg($thumb, $output, 100);copy($photo, $output);
}
return true;return false;
}
}
public function envio($img,$destino,$nomedef=''){
if(!$img){
return false;$file_name = $img['name'];
$file_type = $img['type'];
$file_size = $img['size'];
$file_tmp_name = $img['tmp_name'];
$error = $img['error'];
$extensao=end(explode(".",$file_name));
if($nomedef!=''){
$novonome=$nomedef;$novonome=date("YmdHisu").uniqid().".".$extensao;
}
if($file_size>$this->tamanho){
return false;
}return false;
}
}
if($error == 0){return $novonome;
}
}return false;
}
}
}
?>Carregando comentários...