Aviso por e-mail de novo post no BD
Preciso de ajuda em um formulario de contato que envia tanto para o banco, como avisa por e-mail que tme um novo registro.
O código está assim
<?php include_once "config.php";?>
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Enviar E-MAIL</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="formulario">
<?php if(isset($_POST["enviar"])){
$nome = strip_tags(trim($_POST['nome']));
$email = strip_tags(trim($_POST['email']));
$tel = strip_tags(trim($_POST['tel']));
$assunto = $_POST['assunto'];
$mensagem = strip_tags(trim($_POST['texto']));
if($nome == '' || $email == '' || $assunto == '' || $mensagem == ''){
$retorno = '<div class="erro">Preencha os campos corretamente!</div>';
}elseif(!preg_match("/^[a-z0-9_\.\-]+@[a-z0-9_\.\-]*[a-z0-9_\-]+\.[a-z]{2,4}$/i", $email)){
$retorno = '<div class="erro">Informe um e-mail valido!</div>';
}else{
$status = '1';
$data = date('d').'/'.date('m').'/'.date('Y');
$cadastra_mensagem = mysql_query("INSERT INTO mensagens (nome, email, tel, assunto, mensagem, status, data) VALUES ('$nome','$email', '$tel','$assunto','$mensagem','$status','$data')");
if($cadastra_mensagem){
$retorno = '<div class="ok">Sucesso, E-MAIL enviado.</div>';
}
}
if(isset($retorno)){echo $retorno;}// Email de notificação para o cliente que existe um novo orçamento
$assunto = "Novo Orçamento";
$origem = "emial de origem";
$destino = "email de destino";
$msg = "
<html>
<head>
<title>Novo Orçamento no Site</title>
<link href=\"$svr/css/default_email.css\" rel=\"stylesheet\" type=\"text/css\">
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">
</head>
<body>
<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
<tr>
<td><div align=\"left\"><img src=\"$svr/img/tarja_email.jpg\" ></div></td>
</tr>
</table>
<table width=\"90%\" border=\"0\" align=\"left\" cellpadding=\"3\" cellspacing=\"3\">
<tr>
<td width=\"100%\">
<table width=\"100%\" border=\"0\" align=\"left\" cellpadding=\"0\" cellspacing=\"0\">
<tr>
<td colspan=\"3\" class=\"link_\"><p align=\"justify\" class=\"texto_pgcentral\">
Há um novo orçamento no site , vizualise-o logando no sistema através do
link abaixo:
<a href=\"http:\site\">www.site</a>
</p>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>";
$headers = "Content-type: text/html; charset=utf-8\n";
$headers.="From: $origem\n";
if(mail($destino, $assunto, $msg, $headers)){$msg_erro = "E-mail enviado com sucesso.";}
else {$msg_erro = urlencode('Problemas no envio do e-mail!');}
}
?>
<form action="" method="post" enctype="multipart/form-data">
<label>
<span>Nome:</span>
<input type="text" name="nome" class="txt bradius" />
</label>
<label>
<span>E-mail:</span>
<input type="text" name="email" class="txt bradius" />
</label>
<label>
<span>Telefone:</span>
<input type="text" name="tel" id="form_buscar" class="txt bradius" />
</label>
<label>
<span>Assunto:</span>
<select name="assunto" class="txt bradius" >
<option
value="escolha">Selecione o Assunto</option>
<option value="orcamentos">Orçamentos</option>
<option value="outros">Outros</option>
</select>
</label>
<label>
<span>Mensagem:</span>
<textarea name="texto" class="txtmsg bradius" cols="30" rows="5">
</textarea>
</label>
<input type="hidden" name="acao" value="enviar" />
<input type="submit" name="enviar" id="enviar" value=" Enviar E-MAIL " class="btn"/>
</form>
</div><!-- Formulario -->
</body>
</html>
Está ok envaindo para o banco normal. Mas ele não informa no e-mail de destino que o banco de dados recebeu um novo registro.
Alguém pode me ajudar?
Discussão (1)
Carregando comentários...