RE: mail

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



hello,
       Yes you are right, the || operator stands for OR , which means ,
if any of those listed fields are empty, do not process the form and
throw a error message instead. If you use && instead of || , it instruct
the php other way around as in , if ($field == "" && $field1 == "") or
otherfield, only process the form , if all these form fields are empty
and not just one. I hope that helps. good luck.

Regards,
Gautam Bhatia
       




On Wed, 2009-05-06 at 02:25 -0300, Emiliano Boragina wrote:
> Hi again,
> 
> Thanks Chris for your quickly answer. I dont test it yet.
> I want to share with all you a very strange, for me, solution:
> 
> <?php 
> $empresa = $_POST["empresa"];
> $nombre = $_POST["nombre"];
> $telefono = $_POST["telefono"];
> $mail = $_POST["mail"];
> $asunto = $_POST["asunto"];
> $mensaje = $_POST["mensaje"];
> 
> if($empresa == "" || $nombre == "" || $telefono == "" || $mail == "" ||
> $asunto == "" || $mensaje == "")
> {
> 	//echo "ERROR";
> 	header('location:contactenos.php?mensaje=error');
> }
> else
> {
> 	$fecha = date("d.m.y H:i");
> 	$mymail = "emilino.boragina@xxxxxxxxx";
>    	$subject = "my company : Contacto web<br>"; 
>    	$contenido .= "Empresa: ".$_POST["empresa"]."<br>";
> 	$contenido .= "Nombre y Apellido: ".$_POST["nombre"]."<br>";
>    	$contenido .= "Telefono: ".$_POST["telefono"]."<br>";
>    	$contenido .= "E-mail: ".$_POST["mail"]."<br>";
> 	$contenido .= "Asunto: ".$_POST["asunto"]."<br>";
> 	$contenido .= "Mensaje: ".$_POST["mensaje"]."<br>";
>    	$contenido .= "El mensaje se escribio el ".$fecha."<br>"; 
>    	$header =
> "From:".$_POST["mail"]."\nReply-To:".$_POST["mail"]."<br>";
>    	$header .= "X-Mailer:PHP/".phpversion()."\n"; 
>    	$header .= "Mime-Version: 1.0\n"; 
> 	$header = "Content-Type: text/html; charset=utf-8\r\n";
> 	//mail($mymail, $subject, utf8_encode($contenido) ,$header);
> 	
> 	//echo $contenido;
> 	header('location:contactenos.php?mensaje=ok');
> }
> ?>
> 
> I want to know somthing: this "||" operator is OR, and de logic in my code
> is: if one of variables is empty and the rest not send the mail, it isnt?
> If I want all field full with data I must to use "&&" AND operator, it isnt?
> Well, if the answer is YES, I tell you: I test with "&&" and send it anyway.
> 
> I dont understand... I am right or not with my afiration?
> Thanks a lot!
> 
> +                                                                          _
>    // Emiliano Boragina _
>    // Diseño & Comunicación //////////////////
> +                                                                          _
>    // emiliano.boragina@xxxxxxxxx  /
>    // 15 40 58 60 02 ///////////////////////////
> +                                                                          _
> 
> -----Mensaje original-----
> De: Chris [mailto:dmagick@xxxxxxxxx] 
> Enviado el: Miércoles, 06 de Mayo de 2009 01:08 a.m.
> Para: Emiliano Boragina
> CC: php-db@xxxxxxxxxxxxx
> Asunto: Re:  mail
> 
> Emiliano Boragina wrote:
> > <?php 
> > if(isset($_POST["empresa"]) && isset($_POST["nombre"]) &&
> > isset($_POST["telefono"]) && isset($_POST["mail"]) &&
> > isset($_POST["asunto"]) && isset($_POST["mensaje"]) )
> > {	
> 
> <snip>
> 
> > I test this code to send mail, but I am testing this printing $contenido.
> > If nothing is ISSET must be print "ERROR", but not, if I send de form
> empty
> > this code print $contenido.
> > It is not working, why?
> 
> Maybe the post variables are there but they are empty.
> 
> $form_vars = array('empresa', 'nombre', 'telefono');
> 
> $error = false;
> foreach ($form_vars as $var) {
>    if (!isset($_POST[$var])) {
>       echo "Error - $var is missing\n";
>       $error =  true;
>       break;
>    }
> 
>    if (empty($_POST[$var])) {
>      echo "Error: $var is empty (no value supplied)\n";
>       $error =  true;
>      break;
>    }
> }
> 
> if ($error) {
>    die();
> }
> 
> send_email_here();
> 
> 
> -- 
> Postgresql & php tutorials
> http://www.designmagick.com/
> 
> 
Regards,
Gautam Bhatia .




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux