Ir ao conteúdo
  • Cadastre-se

Envio automático de e-mail após postagem de arquivos.


rodrigosoa

Posts recomendados

Olá pessoal, tenho esse sistema que disponibiliza arquivos para download para clientes cadastrados no site.

Quando o cliente se cadastra ele recebe um e-mail de confirmação aguardando ser aceito, após o administrador do site aprovar o cadastro o cliente recebe outro e-mail de confirmação.

 

Agora no sistema de postagem falta apenas avisar o cliente por e-mail quando um arquivo está disponível para download no site.

 

A sessão abaixo avisa o cliente quando o cadastro foi aprovado, tentei aplicar para avisar quando um arquivo é enviado mas não deu certo, por favor me ajudem com isso.

 

desde já obrigado.

<?php								}		}	}		if ($_GET['action'] == 'aprovar') {		if(isset($_POST["CLIENTE"])) {			foreach($_POST["CLIENTE"] as $id) {				if ($_POST["ativo".$id] == 's') {					$sql = mysql_query("UPDATE cliente SET ativo = '".$_POST["ativo".$id]."' WHERE id = '".$id."'");										$to  = $_POST['email'];					$subject = "Cadastro Aprovado";					$enviar = "					<html>						<body style='font-family:font-family:Verdana, Arial, Helvetica, sans-serif;font-size:12px;color:#000000'>							<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">								<tr>																<td><img src=\"http://www.site.com.br/images/logo_footer.png\" width=\"168\" height=\"133\" /></td>						</tr>						<tr>							<td><img src=\"http://www.site.com.br/images/linha.jpg\" width=\"750\" height=\"1\" /></td>								</tr>								<tr>									<td style=\"padding-top:10px\">										Olá <strong>".$_POST['nome']."</strong>, sua solicitação de cadastro foi aceita em nosso sistema. A partir de agora você pode acessar seus arquivos dentro de nosso site, basta informar seu usuário e senha para acessar sua área.<br /><br />										Atenciosamente<br />										Empresa<br />										http://www.site.com.br									</td>								</tr>							</table>						</body>					</html>					";					$headers = "Content-Type: text/html; charset=iso-8859-1\r\n"; 					$headers.= "From: Empresa <[email protected]>"; 				   					mail($to, $subject, $enviar, $headers);?>

Código completo:

<?phplogado();	if ($_GET['action'] == 'sendfile') {				if ($_FILES['arquivo']['name'] != null) {						$sql1 = mysql_query("SELECT id FROM arquivos WHERE idcliente = '".$_POST['idcliente']."' ORDER BY id DESC LIMIT 1");			$num = mysql_num_rows($sql1);			$aux = mysql_fetch_object($sql1);						$novo = $num == 0 ? '1' : $aux->id + 1;						$uploaddir = "../files/arquivos/";			$ext  = explode(".", $_FILES['arquivo']['name']);			$nome = substr($_FILES['arquivo']['name'],0,-4);			$uploadfile = $uploaddir . $_FILES['arquivo']['name'];			$_FILES['arquivo']['name'] = $_POST['idcliente']."_".$novo."_".date("Y")."_".date("m")."_".date("d").".".$ext[1];						$sql2 = mysql_query("INSERT INTO arquivos (idcliente,nome,link,data,descricao) VALUES ('".$_POST['idcliente']."','".$nome."','".$_FILES['arquivo']['name']."','".date("Y-m-d")."','".$_POST['editor1']."')");						if (move_uploaded_file($_FILES['arquivo']['tmp_name'], $uploaddir . $_FILES['arquivo']['name'])) {						?>                    <meta http-equiv = "Refresh" content = "2; URL = ?pg=cliente">                    <div id="success">O arquivo foi enviado para o cliente</div><?php								} else {?>                    <meta http-equiv = "Refresh" content = "2; URL = ?pg=cliente">                    <div id="error">O arquivo não foi enviado para o cliente</div><?php								}		}	}		if ($_GET['action'] == 'aprovar') {		if(isset($_POST["CLIENTE"])) {			foreach($_POST["CLIENTE"] as $id) {				if ($_POST["ativo".$id] == 's') {					$sql = mysql_query("UPDATE cliente SET ativo = '".$_POST["ativo".$id]."' WHERE id = '".$id."'");										$to  = $_POST['email'];					$subject = "Cadastro Aprovado";					$enviar = "					<html>						<body style='font-family:font-family:Verdana, Arial, Helvetica, sans-serif;font-size:12px;color:#000000'>							<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">								<tr>																<td><img src=\"http://www.site.com.br/images/logo_footer.png\" width=\"168\" height=\"133\" /></td>						</tr>						<tr>							<td><img src=\"http://www.site.com.br/images/linha.jpg\" width=\"750\" height=\"1\" /></td>								</tr>								<tr>									<td style=\"padding-top:10px\">										Olá <strong>".$_POST['nome']."</strong>, sua solicitação de cadastro foi aceita em nosso sistema. A partir de agora você pode acessar seus arquivos dentro de nosso site, basta informar seu usuário e senha para acessar sua área.<br /><br />										Atenciosamente<br />										Empresa<br />										http://www.site.com.br									</td>								</tr>							</table>						</body>					</html>					";					$headers = "Content-Type: text/html; charset=iso-8859-1\r\n"; 					$headers.= "From: Empresa <[email protected]>"; 				   					mail($to, $subject, $enviar, $headers);?>                    <meta http-equiv = "Refresh" content = "2; URL = ?pg=cliente">                    <div id="success">O cadastro foi aceito</div><?php									} else if ($_POST["ativo".$id] == 'n' && $_POST["excluir".$id] == 's') {						$sql = mysql_query("UPDATE cliente SET ativo = 'n', excluir = 's' WHERE id = '".$id."'");					?>                    <meta http-equiv = "Refresh" content = "2; URL = ?pg=cliente">                    <div id="success">O cadastro não foi aceito</div><?php									}			}		}	}		if ($_GET['action'] == 'excluir') {		if(isset($_POST["UIDL"])) {			foreach($_POST["UIDL"] as $id) {				$sql = mysql_query("SELECT * FROM arquivos WHERE id = '".$id."'");				$aux = mysql_fetch_object($sql);				unlink("../files/arquivos/".$aux->link."");				$sql = mysql_query("DELETE FROM arquivos WHERE id = '".$id."'");			}?>                <meta http-equiv = "Refresh" content = "1; URL = ?pg=cliente">                <div id="success">O arquivo foi removido</div><?php	} else {	?>                <meta http-equiv = "Refresh" content = "1; URL = ?pg=cliente">                <div id="error">Por favor, selecione o arquivo que deseja excluir</div><?php					}	}	?><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /><fieldset>    <legend><h1>Administrar conteúdo CLIENTE</h1></legend>    <h3>Enviar arquivo</h3>    <div>        <div id="clienteForm">        <form action="?pg=cliente&action=sendfile" name="form" id="form" method="post" enctype="multipart/form-data">            <p>Selecione o cliente que deseja enviar o arquivo</p>            <select id="idcliente" name="idcliente" style="height:30px;font-size:16px;color:#333">            	<option>Selecione o cliente</option><?php				$sql = mysql_query("SELECT * FROM cliente WHERE ativo = 's' ORDER BY nome");				while ($result = mysql_fetch_object($sql)) {?>            	<option value="<?php echo $result->id; ?>"><?php echo $result->empresa; ?> - <?php echo $result->nome; ?></option><?php			}	?>                            </select><br>            <br>            <input name="arquivo" type="file" style="height:30px;font-size:12px;color:#333" /><br>            <p>Descrição do arquivo</p><textarea name="editor1" style="width:100%;height:450px"><?php echo $result->conteudo; ?></textarea>            <input name="enviar" type="submit" value="Enviar" style="font-size:16px;color:#333" />        </form>        </div>    </div>    <div id="clienteAprovar">      <h3>Aprovar cliente</h3>      <form action="?pg=cliente&action=aprovar" name="form" id="form" method="post" enctype="multipart/form-data">         <?php				$sql2 = mysql_query("SELECT * FROM cliente WHERE ativo = 'n' AND excluir = 'n' ORDER BY nome");				$num = mysql_num_rows($sql2);								if ($num > 0) {?>					 <p style="padding-left:33px"><input name="enviar" type="submit" value="Confirma" style="font-size:16px;color:#333" /></p> <?php										while ($res = mysql_fetch_object($sql2)) {?>                <div id="CollapsiblePanel<?php echo $res->id; ?>" class="CollapsiblePanel">          <div class="CollapsiblePanelTab" tabindex="0"><?php echo $res->nome; ?> - <em><?php echo $res->empresa; ?></em></div>          <div class="CollapsiblePanelContent">          	<p><strong><?php echo $res->empresa; ?></strong></p>            <p><?php echo $res->endereco; ?>, <?php echo $res->numero; ?> - <?php echo $res->complemento; ?></p>            <p><?php echo $res->cidade; ?> - CEP: <?php echo $res->cep; ?></p>            <p>Telefone/Fax: (<?php echo $res->ddd; ?>) <?php echo $res->telefone; ?> / <?php echo $res->fax; ?></p>          	<div id="clienteSimNao"><strong>Aprovar:</strong><input name="ativo<?php echo $res->id; ?>" type="radio" value="s" checked="checked" /> Sim <input name="ativo<?php echo $res->id; ?>" type="radio" value="n" />Não <strong>Excluir:</strong><input name="excluir<?php echo $res->id; ?>" type="checkbox" value="s" />            	            </div>            <input type="hidden" name="CLIENTE[]" value="<?php echo $res->id; ?>" />            <input type="hidden" name="nome" value="<?php echo $res->nome; ?>" />            <input type="hidden" name="email" value="<?php echo $res->email; ?>" />          </div>      </div><?php								}				} else {?>                      					<h2 style="text-align:center">Não há clientes para serem aprovados</h2><?php				}?>    </form>    </div>    <div id="gerenciarArquivo">    	<h3>Gerenciar arquivos</h3>        <form action="?pg=cliente&action=cliente" method="post" name="form" enctype="multipart/form-data">        	            <p>Selecione o cliente que deseja gerenciar os arquivos<br />            	<select name="idcliente" id="idcliente">                	<option>-</option><?php										$sql5 = mysql_query("SELECT * FROM cliente WHERE ativo = 's' ORDER BY nome");					while ($r = mysql_fetch_object($sql5)) {?>                                    	<option value="<?php echo $r->id; ?>"><?php echo $r->empresa." - ".$r->nome; ?></option><?php				}	?>                                    </select>            <input name="ok" type="submit" value="ok" />            </p>        </form>        <br />        <form action="?pg=cliente&action=excluir" method="post" name="form" enctype="multipart/form-data">      <?php		$sql3 = mysql_query("SELECT * FROM cliente WHERE id = '".$_POST['idcliente']."' ORDER BY nome");		$aaa = mysql_fetch_object($sql3);				echo $nome = $_POST['idcliente'] == null ? "" : "<h1><strong>".$aaa->empresa." - ".$aaa->nome."</h1></strong>";		$sql4 = mysql_query("SELECT * FROM arquivos WHERE idcliente = '".$_POST['idcliente']."'");		while ($ret = mysql_fetch_object($sql4)) {?>        			<p style="padding-left:15px;"><input type="checkbox" name="UIDL[]" value="<?php echo $ret->id ?>" /><strong><?php echo $ret->nome.":</strong> ".$ret->descricao; ?></p><hr /><?php				}?>			<input name="excluir" type="submit" value="Excluir" style="font-size:16px;color:#333;float:right" />            <input type="hidden" name="idcliente" value="<?php echo $_POST['idcliente']; ?>" />    	</form>    </div></fieldset>    <script type="text/javascript"><?php		$sql2 = mysql_query("SELECT * FROM cliente WHERE ativo = 'n' ORDER BY nome");		while ($res = mysql_fetch_object($sql2)) {?>var CollapsiblePanel<?php echo $res->id; ?> = new Spry.Widget.CollapsiblePanel("CollapsiblePanel<?php echo $res->id; ?>", {contentIsOpen:false});<?php	}	?>                      </script>
Link para o comentário
Compartilhar em outros sites

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Sobre o Clube do Hardware

No ar desde 1996, o Clube do Hardware é uma das maiores, mais antigas e mais respeitadas comunidades sobre tecnologia do Brasil. Leia mais

Direitos autorais

Não permitimos a cópia ou reprodução do conteúdo do nosso site, fórum, newsletters e redes sociais, mesmo citando-se a fonte. Leia mais

×
×
  • Criar novo...