Aprenda a fazerum formulario de contato simples
Ola pessoal do Copia Isso hoje vou ensinar a voce como fazer um formulario em php vamos lá.
Crie um fomulário com o script abaixo: configure o formulário como vc desejar no Dreamweaver ou seu editor HTML.
Formulario.htm
<!-- INICIO DO CÓDIGO -->
</table>
<form action="formail.php" method="POST">
<font face="Arial Narrow">
<input type="hidden" name="emaildest" value="seuendereço@seuservidor.com.br"></font>
<font face="Arial Narrow">
<input type="hidden" name="redirecionar" value="http://www.suapagina.com.br/msgenviada.htm ">
</font>
<center>
<table width="635" bgcolor="#000000" border="0" align="center" cellspacing="0" cellpadding="1" height="270">
<tr>
<td width="633" height="268">
<div align="center">
<center>
<table width="344" bgcolor="#C4C4AA" border="1" cellspacing="0" cellpadding="3" style="border-collapse: collapse" bordercolor="#111111" height="271">
<tr>
<td width="93" height="22"><font face="Tahoma" size="2">Seu nome:</font></td>
<td width="239" height="22">
<font face="Arial Narrow">
<input type="text" size="70" name="nome" value=""></font></td>
</tr>
<tr>
<td width="93" height="22"><font face="Tahoma" size="2">Seu E-mail:</font></td>
<td width="239" height="22">
<font face="Arial Narrow">
<input type="text" size="70" name="email" value=""></font></td>
</tr>
<tr>
<td width="93" height="22"><font face="Tahoma" size="2">Assunto:</font></td>
<td width="239" height="22">
<font face="Arial Narrow">
<input type="text" size="70" name="assunto" value=""></font></td>
</tr>
<tr>
<td width="93" height="100"><font face="Tahoma" size="2">Mensagem:</font></td>
<td width="239" height="100">
<font face="Arial Narrow">
<textarea cols="60" rows="6" name="mensagem"></textarea></font></td>
</tr>
<tr>
<td colspan="2" align="center" width="331" height="71">
<font face="Arial Narrow">
<input type="submit" value=" Enviar " style="float: left; font-family: Tahoma"></font><font face="Tahoma"><input type="reset" value=" Limpar " style="float: left"></font><font face="Arial Narrow">
</font></td>
</tr>
</table>
</center>
</div>
</td>
</tr>
</table>
</center>
</form>
<p align="center">
<a href="corpo.asp"><strong><font color="#000000" face="Tahoma" size="3">Voltar</font></strong></a></p>
</body>
<!-- FIM DO CODIGO -->
Agora o vai a página : formail.php
<!-- INICIO DO CÓDIGO -->
<?php require "config.ini"; ?>
<?php
ini_set ("SMTP","smtp.eb.mil.br");
////////////////////////////////////////////////
// Formail em PHP por Copia Isso |||
// Esse formulario é uma imitação do formail |||
// com um pequena ponto fraco |||
// ao adicionar um novo campo ele tera |||
// quer ser mudado aqui nesse arquivo |||
/////////////////////////////////////////////|||
// Carrega dados pelo método POST, independente da configuração das variáveis Globais do ini do PHP
$nome=$_POST["nome"];
$email=$_POST["email"];
$assunto=$_POST["assunto"];
$mensagem=$_POST["mensagem"];
// Verifica se O Campo nome tá preenchido
if (empty($nome)){
// HTML que aparecera o ERRO
echo "<html><head><title>Ocorreu Um ERRO !!!</title></head>";
echo "<body bgcolor=\"#ffffff\">";
echo "<br><br><br>";
echo "<center>É Necessario o Preenchimento do <b>Nome</b></center>";
echo "<br><br><center><a href=\"javascript:history.back(1)\">Volta</a></center>";
echo "</body></html>";
}
// Verifica o Campo E-mail Tá preenchido
elseif (empty($email)){
// HTML que aparecera o ERRO
echo "<html><head><title>Ocorreu Um ERRO !!!</title></head>";
echo "<body bgcolor=\"#ffffff\">";
echo "<br><br><br>";
echo "<center>O E-mail não foi <b>Digitado</b></center>";
echo "<br><br><center><a href=\"javascript:history.back(1)\">Volta</a></center>";
echo "</body></html>";
}
// Verifoca Se o E-mail Contem @
elseif (!(strpos($email,"@")) OR strpos($email,"@") !=strrpos($email,"@")) {
// HTML que aparecera o ERRO
echo "<html><head><title>Ocorreu Um ERRO !!!</title></head>";
echo "<body bgcolor=\"#ffffff\">";
echo "<br><br><br>";
echo "<center>O E-mail <b>Não</b> é <b>válido</b></center>";
echo "<br><br><center><a href=\"javascript:history.back(1)\">Volta</a></center>";
echo "</body></html>";
}
// Verifica se o Campo Está Preenchido
elseif (empty($assunto)){
// HTML que aparecera o ERRO
echo "<html><head><title>Ocorreu Um ERRO !!!</title></head>";
echo "<body bgcolor=\"#ffffff\">";
echo "<br><br><br>";
echo "<center>Você <b>Não</b> Digitou Um <b>Assunto</b></center>";
echo "<br><br><center><a href=\"javascript:history.back(1)\">Volta</a></center>";
echo "</body></html>";
}
// Verifica se o Campo Mensagem tá preenchido
elseif (empty($mensagem)){
// HTML que aparecera o ERRO
echo "<html><head><title>Ocorreu Um ERRO !!!</title></head>";
echo "<body bgcolor=\"#ffffff\">";
echo "<br><br><br>";
echo "<center>Você <b>Não</b> Digitou Uma <b>Mensagem</b></center>";
echo "<br><br><center><a href=\"javascript:history.back(1)\">Volta</a></center>";
echo "</body></html>";
}
else{
// Comfirma o Envio Do E-mail
if ($certo== "1")
{
// Função de envio Do E-mail
//mail ("seuendereço@seuservidor.com.br ","nome","string message", "string additional_headers");
mail ("$emaildest","$assunto","Nome:$nome\n Email:$email\n Mensagem:$mensagem\n IP:$REMOTE_ADDR\n\n ...::: Coloque seu nome aqui ou o nome da empresa ® :::...","From:$nome<$email>");
}
// HTML do redirecionameto e se não redirecionar aparece um link
echo "<html><head>";
echo "<meta http-equiv=\"refresh\" content=\"0;url=$redirecionar\">";
echo "<title>Redirecionado ...</title>";
echo "</head><body bgcolor=\"#ffffff\">";
echo "<a href=\"$redirecionar\" target=\"_top\">Volta Para O Site</a>";
echo "</body></html>";
}
?>
<!-- FIM DO CODIGO -->
Bom agora para completar vc precisa colocar no servidor o arquivo: config.ini
<!-- INICIO DO CÓDIGO -->
<?php
// Isto é quase como uma chave se vc não quiser mais receber mensagems é só colocar 0
// 1 = Ligado - 0 = Desligado
//
$certo="1";
$emaildest="seuendereço@seuservidor.com.br ";
$redirecionar="http://www.suapagina.com.br/msgenviada.htm"
?>
<!-- FIM DO CODIGO -->

Postar um comentário