Ir para conteúdo
Fórum Script Brasil
  • 0

(Resolvido) Formulario de contato com email selecionavel


Marcos Adriano

Pergunta

Olá pessoal, será que alguém tem um modelo de formulario de contato com email selecionavel, estou precisando urgente de um, pois quero que o visitante escolha para qual setor quer mandar o email.

Vejam um exemplo:

http://www.sudati.com.br/web/site/?p=10.html.

Grato a quem me ajudar.

Link para o comentário
Compartilhar em outros sites

6 respostass a esta questão

Posts Recomendados

  • 0

Coloca mais um campo ali com a área que o usuário deseja contactar, no formato combo box (select) como no do assunto, e nos values coloca os e-mails.

No PHP, na hora de puxar os dados, puxa esse e-mail junto e salva em uma variável.

Depois é só colocar essa variável na função mail().

Link para o comentário
Compartilhar em outros sites

  • 0

Obrigado MLeandroJr!, vou tentar aqui.da uma olhada nesse meu outro formulario e me diga o que tenho que mudar no php.

Desde já agradeço.

HTML

<table width="90%" border="0" cellpadding="0" cellspacing="0">
                    <tr>
                      <td><img src="imgs/c_1_5.gif" width="17" height="20" /></td>
                      <td background="imgs/c_1_3.gif">&nbsp;</td>
                      <td><img src="imgs/c_1_6.gif" width="17" height="20" /></td>
                    </tr>
                    <tr>
                      <td width="17" background="imgs/c_1_1.gif"><img src="imgs/c_1_1.gif" width="17" height="2" /></td>
                      <td bgcolor="#FFFFFF">
                                            
                      
                      <form action="" method="post"  id="contato.php" style="padding:0; margin:0;">
                      
                      <table width="100%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                          <td width="65%"><table width="100%" border="0" cellspacing="0" cellpadding="10">
                            <tr>
                              <td class="textoCinz"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                <tr>
                                  <td width="80%"><span class="tituloPreto" ><strong>Empresa.</strong></span><br />
                                    <br />
Rua, numero, bairro<br />
CEP, cidade, estado<br />
telefone</td>
                                </tr>
                              </table></td>
                            </tr>
                          </table>
                            <table width="100%" border="0" cellspacing="2" cellpadding="2">
                              <tr>
                                <td class="titulo_azul"><table width="100%" border="0" cellspacing="0" cellpadding="2">
                                    <tr>
                                      <td width="4"><img src="imgs/sera.gif" width="4" height="5" /></td>
                                      <td class="titulo_azul1"><label>Departamento</label></td>
                                    </tr>
                                </table></td>
                              </tr>
                              <tr>
                                <td><select name="recipient" id="recipient" class="input">
                                  <option value="contato@exemplo.com.br" selected="selected">Contato Geral</option>
                                  <option value="rh@exemplo.com.brr">RH</option>
                                  <option value="vendas@exemplo.com.br">Vendas</option>
                                  <option value="compras@exemplo.com.br">Compras</option>
                                </select>
                                </td>
                              </tr>
                              <tr>
                                <td class="titulo_azul"><table width="100%" border="0" cellspacing="0" cellpadding="2">
                                    <tr>
                                      <td width="4"><img src="imgs/sera.gif" width="4" height="5" /></td>
                                      <td class="titulo_azul1"><label>Nome Completo*</label></td>
                                    </tr>
                                </table></td>
                              </tr>
                              <tr>
                                <td><input type="text" name="nome" id="nome" class="input"/></td>
                              </tr>
                              <tr>
                                <td height="30" valign="bottom"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                    <tr>
                                      <td width="69%"><table width="100%" border="0" cellspacing="0" cellpadding="2">
                                          <tr>
                                            <td width="4"><img src="imgs/sera.gif" width="4" height="5" /></td>
                                            <td class="titulo_azul"><label>Cidade*</label></td>
                                          </tr>
                                      </table></td>
                                      <td width="1%">&nbsp;</td>
                                      <td width="30%"><table width="100%" border="0" cellspacing="0" cellpadding="2">
                                          <tr>
                                            <td width="4"><img src="imgs/sera.gif" width="4" height="5" /></td>
                                            <td class="titulo_azul"><label>Estado*</label></td>
                                          </tr>
                                      </table></td>
                                    </tr>
                                </table></td>
                              </tr>
                              <tr>
                                <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                    <tr>
                                      <td width="69%"><input type="text" name="cidade" id="cidade" class="input"/></td>
                                      <td width="1%">&nbsp;</td>
                                      <td width="30%"><input type="text" name="estado" id="estado" class="input" style="text-transform:uppercase" maxlength="2"/></td>
                                    </tr>
                                </table></td>
                              </tr>
                              <tr>
                                <td height="30" valign="bottom"><table width="100%" border="0" cellspacing="0" cellpadding="2">
                                    <tr>
                                      <td width="4"><img src="imgs/sera.gif" width="4" height="5" /></td>
                                      <td class="titulo_azul"><label>Telefone*</label></td>
                                    </tr>
                                </table></td>
                              </tr>
                              <tr>
                                <td><input type="text" name="telefone" id="telefone" class="input" maxlength="13" />
                                    <script>
                                        $("#telefone").mask("(99)9999-9999");
                                        </script></td>
                              </tr>
                              <tr>
                                <td height="30" valign="bottom"><table width="100%" border="0" cellspacing="0" cellpadding="2">
                                    <tr>
                                      <td width="4"><img src="imgs/sera.gif" width="4" height="5" /></td>
                                      <td class="titulo_azul"><label>E-mail*</label></td>
                                    </tr>
                                </table></td>
                              </tr>
                              <tr>
                                <td><input type="text" name="email" id="email" class="input" /></td>
                              </tr>
                              <tr>
                                <td height="30" valign="bottom"><table width="100%" border="0" cellspacing="0" cellpadding="2">
                                    <tr>
                                      <td width="4"><img src="imgs/sera.gif" width="4" height="5" /></td>
                                      <td class="titulo_azul"><label>Mensagem*</label></td>
                                    </tr>
                                </table></td>
                              </tr>
                              <tr>
                                <td><textarea name="msg" id="msg" rows="6"  style="width: 100%" class="texto textarea"></textarea>                                </td>
                              </tr>
                              <tr>
                                <td><table cellpadding="0" cellspacing="0" border="0">
                                    <tr>
                                      <td></td>
                                      <td></td>
                                    </tr>
                                </table></td>
                              </tr>
                            </table>
                            <table width="100%" border="0" cellspacing="0" cellpadding="4"><tr><td><label></label></td>
                              </tr>
                            </table>
                            <table width="100%" border="0" cellspacing="0" cellpadding="0">
                              <tr>
                                <td onclick="validaFormContato();"><div align="right" style="cursor:pointer;">
                                  <input name="enviado" type="hidden" id="enviado" value="ok" />
                                  <img src="imgs/bt_enviar.gif" width="118" height="23" /></div></td>
                              </tr>
                            </table></td>
                        </tr>
                      </table></form>
                                            </td>
                      <td width="17" background="imgs/c_1_2.gif"><img src="imgs/c_1_2.gif" width="17" height="2" /></td>
                    </tr>
                    <tr>
                      <td><img src="imgs/c_1_8.gif" width="17" height="20" /></td>
                      <td background="imgs/c_1_4.gif">&nbsp;</td>
                      <td><img src="imgs/c_1_7.gif" width="17" height="20" /></td>
                    </tr>
</table>
PHP
<?
$to = “exemplo@exemplo.com”;
$nome = $_POST['nome'];
$email = $_POST['email'];
$assunto = $_POST['assunto'];
$msg = $_POST['mensagem'];
$msg = nl2br($msg); 
if($nome == NULL || $email == NULL || $assunto == NULL || $msg == NULL):
?>
<script language=”JavaScript”>alert(’H campos requeridos em branco!’);
location.href=’http://exemplo.com/contato.htm’;
</script>
<?
exit;
endif;
$pattern = “^([A-Z_a-z])+@([a-zA-Z])+”;
if(ereg($pattern,$email) == false):
?>
<script language=”JavaScript”>alert(’O email no válido’);
location.href=’http://exemplo.com/contato.htm’;
</script>
<?
exit;
endif;
$mensagem = “Mensagem enviada por: “.$nome.” em: “.date(”d/m/Y - H:i”).”\n <br />
Abaixo seguem os dados do usuário:\n <br />
E-mail: “.$email.”\n <br />
Assunto: “.$assunto.”\n <br />
A mensagem enviada a você foi a seguinte: \n <br />
“.$msg;
$headers = “MIME-Version: 1.0\r\n”;
$headers .= “Content-type: text/html; charset=iso-8859-1\r\n”;
$headers .= “From: $email <$email>\r\n”;
mail($to,$assunto,$mensagem,$headers);
?>
// Abre uma janela confirmando o envio e redirecionando para “index.htm”.
<script language=”JavaScript”>alert(’Sua mensagem foi enviada com êxito!’);
location.href=’http://exemplo.com/’;
</script>

Link para o comentário
Compartilhar em outros sites

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,3k
    • Posts
      652,3k
×
×
  • Criar Novo...