Page 1 of 1

php mail() - create required fields and e-mail verification

Posted: Fri May 13, 2005 6:34 am
by alapimba
Hello, i'm new to this forum and i have a question that i guess it's very simple but i can't find the answer on the forum so here it is.
I want to verify if none of the fields are blank and also if the user entered a valid mail(xxx@xxx.xxx)
My code so far is this and it's working fine.

Code: Select all

<form name=&quote;form1&quote; method=&quote;post&quote; action=&quote;form_sugestoes.php&quote;>
                                  <span class=&quote;style5&quote;><br>
                                  Nome:</span><br>
                                  <input name=&quote;nome&quote; type=&quote;text&quote; id=&quote;nome&quote; size=&quote;50&quote;>
                                  <br>
                                  <span class=&quote;style5&quote;><br>
                                  E-mail:
                                  </span><br>
                                  <input name=&quote;mail&quote; type=&quote;text&quote; id=&quote;mail&quote; size=&quote;50&quote;>
                                  <br>
                                  <span class=&quote;style5&quote;><br>
                                  Empresa:
                                  </span><br>
                                  <input name=&quote;empresa&quote; type=&quote;text&quote; id=&quote;empresa&quote; required=&quote;required size=&quote;50&quote;>
                                  <br>
                                  <span class=&quote;style5&quote;><br>
                                  Sugestão:</span><br>
                                  <textarea name=&quote;mensagem&quote; cols=&quote;38&quote; rows=&quote;5&quote; wrap=&quote;VIRTUAL&quote; id=&quote;mensagem&quote;></textarea>
                                  <br>
                                  <br>
                                  <input type=&quote;submit&quote; name=&quote;Submit&quote; value=&quote;Enviar&quote;>
                                                                                                </form>
and the php code from the file form_sugestoes.php

Code: Select all

<?php
$sendTo = "xxx@hotmail.com";
$subject = "Sugestão sobre site xxx";
$headers  = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: " . $_POST["nome"];
$headers .= "<" . $_POST["mail"] .">\r\n";
$headers .= "Reply-To: " . $_POST["mail"];

// varaveis
$nome= $_POST["nome"];
$mail= $_POST["mail"];
$empresa= $_POST["empresa"];
$mensagem= $_POST["mensagem"];

/* message */
$message =
"<html>
<head>
 <title>xxx</title>
</head>
<body>
<p><strong>nome:</strong>$nome</p>
<p><strong>mail:</strong>$mail</p>
<p><strong>empresa:</strong>$empresa</p>
<p><strong>mensagem:</strong>$mensagem</p>

</body>
</html>";

mail($sendTo, $subject, $message, $headers);
header("Location: sugestoes_yes.php");
?>

Re: php mail() - create required fields and e-mail verificat

Posted: Fri May 13, 2005 6:48 am
by malcolmboston
alapimba wrote: I want to verify if none of the fields are blank and also if the user entered a valid mail(xxx@xxx.xxx)
as an extension of this, is it possible to make sure an email address actually exists (this is not for spam purposes, i dont even really have a use for it for the moment but thinking for the future..)

Posted: Fri May 13, 2005 6:51 am
by alapimba
if theres a chance to verify if the mail really exist that's even better. I just thought it was too hard and wanted the simplest way.
Can you help me?

Posted: Fri May 13, 2005 6:52 am
by JayBird
alapimba wrote:if theres a chance to verify if the mail really exist that's even better. I just thought it was too hard and wanted the simplest way.
Can you help me?
You can do it, search these forums, its been discussed many times before. The conclusion most threads come to is that it is not 100% accurate. The better way is to send an email with a verification link.

viewtopic.php?t=29067&highlight=check+c ... mail+exist

Posted: Fri May 13, 2005 8:25 am
by alapimba
And how can i make some fileds to be required to the form be sent? Can you explain me please?