← Desenvolvimento

php mail form validator!

Lida 8343 vezes

Offline

cenourinha 
Elite
Mensagens 4094 Gostos 21
Troféus totais: 34
Trófeus: (Ver todos)
Mobile User Apple User Level 6 Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4

Código: [Seleccione]
<?php

$nome 
$_POST['nome'&#93;;
$mail $_POST['mail'&#93;;
$assunto $_POST['assunto'&#93;;
$msg $_POST['msg'&#93;;

if &#40;$nome == $null and $mail == $null and $assunto == $null and $msg == $null&#41;
&#123;
echo&#40;"Não foram inseridos nenhuns dados nos campos"&#41;;
&#125;
elseif &#40;$nome == $null&#41;
&#123;
echo&#40;"Não foi inserido o nome"&#41;;
&#125;
elseif &#40;$mail == $null&#41;
&#123;
echo&#40;"Não foi inserido o e-mail!"&#41;;
&#125;
elseif &#40;$assunto == $null&#41;
&#123;
echo&#40;"Não foi inserido o assunto!"&#41;;
&#125;
elseif &#40;$msg == $null&#41;
&#123;
echo&#40;"Não foi inserida a mensagem!"&#41;;
&#125;
else

&
#123;
  
function checkemail&#40;$email&#41; &#123;
    
if&#40;eregi&#40;"^[0-9a-z&#93;&#40;[-_.&#93;?[0-9a-z&#93;&#41;*@[0-9a-z&#93;&#40;[-.&#93;?[0-9a-z&#93;&#41;*\\.[a-z&#93;&#123;2,4&#125;$",$email&#41;&#41;  &#123;
$dia date&#40;d&#41;;
$mes date&#40;m&#41;;
$ano date&#40;y&#41;;
$ip $REMOTE_ADDR;

$mensagem="$msg \n \n \n Enviado por $nome cujo o e-mail é $mail \n Dia&#58; $dia Mês&#58; $mes Ano&#58; $ano \n IP&#58; $ip ";

$header="from&#58; $nome <$mail>";

$para ='webtuga@gmail.com';

$pedir_convite=mail&#40;$para,$assunto,$mensagem,$header&#41;;

echo "Recebe-mos o seu e-mail com sucesso! Quando possivel iremos tentar responder-lhe!\n";
&
#125;

    
else &#123;
    
echo&#40;"O e-mail é invalido!"&#41;;
    
&#125;
    
&#125;
&#125;
?>


Need help!

O que é que está mal?
Offline

Bruno Mota 
Membro
Mensagens 1733 Gostos 3
Troféus totais: 28
Trófeus: (Ver todos)
Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4 Level 3 Level 2 Level 1

qual é o erro que te da?
Offline

cenourinha 
Elite
Mensagens 4094 Gostos 21
Troféus totais: 34
Trófeus: (Ver todos)
Mobile User Apple User Level 6 Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4

Aparece uma pagina em branco do template e não envia o mail!

http://cenourinha.gethost4you.com/index.php?p=contactos
Offline

Bruno Mota 
Membro
Mensagens 1733 Gostos 3
Troféus totais: 28
Trófeus: (Ver todos)
Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4 Level 3 Level 2 Level 1

no post no form mete mesmo o url original tenta la
Offline

cenourinha 
Elite
Mensagens 4094 Gostos 21
Troféus totais: 34
Trófeus: (Ver todos)
Mobile User Apple User Level 6 Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4

Offline

Bruno Mota 
Membro
Mensagens 1733 Gostos 3
Troféus totais: 28
Trófeus: (Ver todos)
Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4 Level 3 Level 2 Level 1

estranho eu ja vou ver isso mais a fundo ainda nao li o cod todo
tou a aturar e a enviar uma cena ao asturmas lol
Offline

morpheus 
Membro
Mensagens 1199 Gostos 0
Troféus totais: 28
Trófeus: (Ver todos)
Super Combination Combination Topic Starter Poll Voter Level 5 Level 4 Level 3 Level 2 Level 1 1000 Posts

não ponhas $null. põe só null
Offline

OFFICER 
Membro
Mensagens 2076 Gostos 0
Troféus totais: 29
Trófeus: (Ver todos)
Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Poll Starter Level 5 Level 4 Level 3 Level 2

Tens sorte, chegou o PHP MASTER  8)

morpheus ao ataque!  :twisted:
Offline

fpware 
Fundador
Mensagens 15318 Gostos 7
Troféus totais: 38
Trófeus: (Ver todos)
Linux User Mobile User Level 6 Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Poll Starter Level 5

Citação de: "OFFICER"
Tens sorte, chegou o PHP MASTER  8)

morpheus ao ataque!  :twisted:


Nem mais!  :D
Offline

OFFICER 
Membro
Mensagens 2076 Gostos 0
Troféus totais: 29
Trófeus: (Ver todos)
Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Poll Starter Level 5 Level 4 Level 3 Level 2

LOL  :lol:
Offline

morpheus 
Membro
Mensagens 1199 Gostos 0
Troféus totais: 28
Trófeus: (Ver todos)
Super Combination Combination Topic Starter Poll Voter Level 5 Level 4 Level 3 Level 2 Level 1 1000 Posts

:mrgreen:

kidmetralha 
Visitante

o IP ñ aparece no e-mail :( cenorinha e k tal meter um code para obrigar o ppl a meter o @ :?:
Offline

OFFICER 
Membro
Mensagens 2076 Gostos 0
Troféus totais: 29
Trófeus: (Ver todos)
Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Poll Starter Level 5 Level 4 Level 3 Level 2

o IP não aparece porque a função não está lá..

Citação de: "cenourinha"
$ip = $REMOTE_ADDR;


Código: [Seleccione]
$ip = getenv("REMOTE_ADDR");

Assim está correcto ;)
Offline

cenourinha 
Elite
Mensagens 4094 Gostos 21
Troféus totais: 34
Trófeus: (Ver todos)
Mobile User Apple User Level 6 Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4

Tenho isto agora e não dá na mesma:

Código: [Seleccione]
<?php

$nome 
$_POST['nome'&#93;;
$mail $_POST['mail'&#93;;
$assunto $_POST['assunto'&#93;;
$msg $_POST['msg'&#93;;

if &#40;$nome == null and $mail == null and $assunto == null and $msg == null&#41;
&#123;
echo&#40;"Não foram inseridos nenhuns dados nos campos"&#41;;
&#125;
elseif &#40;$nome == null&#41;
&#123;
echo&#40;"Não foi inserido o nome"&#41;;
&#125;
elseif &#40;$mail == null&#41;
&#123;
echo&#40;"Não foi inserido o e-mail!"&#41;;
&#125;
elseif &#40;$assunto == null&#41;
&#123;
echo&#40;"Não foi inserido o assunto!"&#41;;
&#125;
elseif &#40;$msg == null&#41;
&#123;
echo&#40;"Não foi inserida a mensagem!"&#41;;
&#125;
else

&
#123;
  
function checkemail&#40;$email&#41; &#123;
    
if&#40;eregi&#40;"^[0-9a-z&#93;&#40;[-_.&#93;?[0-9a-z&#93;&#41;*@[0-9a-z&#93;&#40;[-.&#93;?[0-9a-z&#93;&#41;*\\.[a-z&#93;&#123;2,4&#125;$",$email&#41;&#41;  &#123;
$dia date&#40;d&#41;;
$mes date&#40;m&#41;;
$ano date&#40;y&#41;;
$ip getenv&#40;"REMOTE_ADDR"&#41;;

$mensagem="$msg \n \n \n Enviado por $nome cujo o e-mail é $mail \n Dia&#58; $dia Mês&#58; $mes Ano&#58; $ano \n IP&#58; $ip ";

$header="from&#58; $nome <$mail>";

$para ='webtuga@gmail.com';

$pedir_convite=mail&#40;$para,$assunto,$mensagem,$header&#41;;

echo "Recebe-mos o seu e-mail com sucesso! Quando possivel iremos tentar responder-lhe!\n";
&
#125;

    
else &#123;
    
echo&#40;"O e-mail é invalido!"&#41;;
    
&#125;
    
&#125;
&#125;
?>
Offline

OFFICER 
Membro
Mensagens 2076 Gostos 0
Troféus totais: 29
Trófeus: (Ver todos)
Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Poll Starter Level 5 Level 4 Level 3 Level 2

Claro, tens a função mail assim um bocado esquisita :?

Citação de: "cenourinha"
$pedir_convite=mail($para,$assunto,$mensagem,$header);


O que faz ali o $pedir_convite=?

Experimenta lá substituir assim:

Código: [Seleccione]
mail($para,$assunto,$mensagem,$header);