dsonesuk Posted August 18, 2009 Share Posted August 18, 2009 Note: I changed $mail to $email;if (isset($_POST['nombre']) || isset($_POST['telefono']) || isset($_POST['email'])) { $nombre = $_POST['nombre']; $telefono = $_POST['telefono']; $email = $_POST['email']; $mensaje = $_POST['mensaje']; $pattern = '/[^0-9]/'; if(empty($nombre) || empty($telefono) || empty($email)) { $errormsg.= "<p style=\"color: red;\">Please Fill In Empty Fields.</p>"; } if(!$email == "" && (!strstr($email,"@") || !strstr($email,"."))) { $errormsg.= "<h2>Vuelva a la pagina anterior, ingrese una direccion de e-mail válida-.</h2>\n"; $errormsg.= "<h2>La informacion no fue ingresada.</h2>\n"; } if (empty($POST['mensaje'])) { $errormsg.= "<h2>Vuelva a la pagina anterior, rellene todas las casillas.</h2>\n"; } if (preg_match($pattern, $telefono)) { $errormsg.= "<p style=\"color: red;\">Invalid Telephone Number entered.</p>"; } if($errormsg == "") // if no errors found go to page.... (this should be at end, below all validation conditions) { header("Location: http://www.laradialautomoviles.com/gracias.html"); } } Link to comment Share on other sites More sharing options...
shoyle Posted August 18, 2009 Author Share Posted August 18, 2009 Theres a mistake on the empty message part scince it comes up every time i clik trhe submit button, but it all seems to be ok :S I pasted my e-mail part and it doesnt work with that either: <?php$nombre = "";$telefono = "";$email = "";$mensaje = "";$errormsg = "";if (isset($_POST['nombre']) || isset($_POST['telefono']) || isset($_POST['email'])){$nombre = $_POST['nombre'];$telefono = $_POST['telefono'];$email = $_POST['email'];$mensaje = $_POST['mensaje'];$pattern = '/[^0-9]/';if(empty($nombre) || empty($telefono) || empty($email)){$errormsg.= "<p style=\"color: red;\">Rellene todos los campos.</p>";}if(!$email == "" && (!strstr($email,"@") || !strstr($email,"."))){$errormsg.= "<h2>Ingrese una direccion de e-mail válida-.</h2>\n";}if (empty($POST['mensaje'])){$errormsg.= "<h2>Rellene todas las casillas.</h2>\n";}if (preg_match($pattern, $telefono)){$errormsg.= "<p style=\"color: red;\">El numero de telefono no es valido.</p>";}$header = 'From: ' . $mail . " rn";$mensaje = "Este mensaje fue enviado por " . $nombre . " ";$mensaje .= "Su telefono es: " . $telefono . " ";$mensaje .= "Su e-mail es: " . $mail . " ";$mensaje .= "Mensaje: " . $_POST['mensaje'] . " " ;$mensaje .= "Enviado el " . date('d/m/Y', time());//-----------------------------------------------------////----------------------------------------------------//$para = 'admin@pumsho.com';$asunto = 'Contacto desde pagina web';mail($para, $asunto, utf8_decode($mensaje), $header);if($errormsg == "") // if no errors found go to page.... (this should be at end, below all validation conditions){header("Location: [url="http://www.laradialautomoviles.com/gracias.html"%3b%29;"]http://www.laradialautomoviles.com/gracias.html");[/url]}} ?> Link to comment Share on other sites More sharing options...
dsonesuk Posted August 19, 2009 Share Posted August 19, 2009 if (empty($POST['mensaje'])) (sorry i did not spot this before, mind you it's been there from the start, and no one picked it up LOL) should be: if (empty($_POST['mensaje']))OR if(empty($mensaje)) Link to comment Share on other sites More sharing options...
shoyle Posted August 19, 2009 Author Share Posted August 19, 2009 works awsome! youre the man!!the only lil problem is thet if they make a mistake they get the "enter valid phone" for example, but on the mesage part you see this: Este mensaje fue enviado por "who sent the mesage" Su telefono es: "the wrong phone number" Su e-mail es: "the email" Mensaje: "the mesage" Enviado el 18/08/2009 so when you correect the mistake you recive an email with the information 2 times repeeted. I dont know if its the order thigs are or wht but I gess it must be that.and a lil one, insted of teh header location gracias.html can i change that for something like mmm echo "your mesage wass sent correctly" would the echo work and apear inside the page correctly? Link to comment Share on other sites More sharing options...
Ingolme Posted August 19, 2009 Share Posted August 19, 2009 You haven't told it not to send the E-mail if the information was wrong: mail($para, $asunto, utf8_decode($mensaje), $header);if($errormsg == "") // if no errors found go to page.... (this should be at end, below all validation conditions){header("Location: http://www.laradialautomoviles.com/gracias.html");} Try this instead: if($errormsg == "") // if no errors found go to page.... (this should be at end, below all validation conditions){ mail($para, $asunto, utf8_decode($mensaje), $header); header("Location: http://www.laradialautomoviles.com/gracias.html");} Link to comment Share on other sites More sharing options...
dsonesuk Posted August 19, 2009 Share Posted August 19, 2009 this is the problem:$mensaje = "Este mensaje fue enviado por " . $nombre . " ";$mensaje .= "Su telefono es: " . $telefono . " ";$mensaje .= "Su e-mail es: " . $mail . " ";$mensaje .= "Mensaje: " . $_POST['mensaje'] . " " ;$mensaje .= "Enviado el " . date('d/m/Y', time());$mensaje is already used for the message content from $_POST['mensaje']. The form uses this to show the message content previously entered after an error is found (prevents re-entering message repeatedly), but now you have added all the email contents to this variable.solution, rename '$mensaje' above to something like '$emailcontent'ALSO '$mail' should be '$email'the '$errormsg' can be used to show 'Congratulations Email Sent' message, but it might be good idea to empty all the field content as well, see below:if($errormsg == "") // if no errors found, send email go to page.... (this should be at end, below all validation conditions){mail($para, $asunto, utf8_decode($emailcontent), $header); //Note change '$mensaje' to $emailcontent $errormsg="<p style=\"color: #00FF00;\"> Message sent Congratulations</p>"; $nombre = "";$telefono = "";$email = "";$mensaje = ""; //header("Location: http://www.laradialautomoviles.com/gracias.html");} Link to comment Share on other sites More sharing options...
shoyle Posted August 19, 2009 Author Share Posted August 19, 2009 cool that works!! but haha this is getting funnyer every time, now I get 2 emails for every time it submits , one that says the e-mail adress of the person who sent it as the sender and only the message inside but not the phone or name, and a second message with the address of my hosting as the sender and all the correct info such as phone name and so on.. Link to comment Share on other sites More sharing options...
shoyle Posted August 19, 2009 Author Share Posted August 19, 2009 never mind, it works good , there was problems with the order of the sentences but when i fixed that it worked good, now, the past thing, how can I add bcc (blind carbon copy)? Link to comment Share on other sites More sharing options...
dsonesuk Posted August 19, 2009 Share Posted August 19, 2009 check out Sending email in PHP which shows you how to send mail with all options below.$headers = 'To: Mary <mary@example.com>' . "\r\n";$headers .= 'Cc: Kelly <kelly@example.com>' . "\r\n";$headers .= 'Bcc: John <john@example.com>, Peter <peter@example.com>' . "\r\n";$headers .= 'From: Matthew <matthew@example.com>' . "\r\n";$headers .= 'MIME-Version: 1.0' . "\r\n";$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; Link to comment Share on other sites More sharing options...
shoyle Posted August 20, 2009 Author Share Posted August 20, 2009 big thanks to you all and specially to dsonesuk !!!! Is good to find people like you guys.. in other forums they criticise you instead of help You are the kinda friends I would like to have in my facebook hahaha Link to comment Share on other sites More sharing options...
shoyle Posted August 21, 2009 Author Share Posted August 21, 2009 when I thought it wass all perfect: SURPRISE!!! when i receive the mail sent through the page, i see : from : laradialautomoviles (the name of the site) and this: (laradialautomoviles@magic.dreamhost.com) I dont understand where that came from !! need help again!!! hehe Link to comment Share on other sites More sharing options...
justsomeguy Posted August 21, 2009 Share Posted August 21, 2009 That's the default address on the server. If you don't want to use the default you need to give it a from address to use, you can use a header for that also like with BCC. If the server ignores your from address and uses its own, it's probably best to contact your host and ask them why. Link to comment Share on other sites More sharing options...
shoyle Posted August 21, 2009 Author Share Posted August 21, 2009 when I look into my php it says $header = 'From: ' . $email . " rn"; witch means that it should say the e-mail of the person who sent it and that way I can also clik on reply and it will reply to the e-mail the person entered. maybe theres something wrong with my code? <?php$nombre = "";$telefono = "";$email = "";$mensaje = "";$errormsg = "";if (isset($_POST['nombre']) || isset($_POST['telefono']) || isset($_POST['email'])){$nombre = $_POST['nombre'];$telefono = $_POST['telefono'];$email = $_POST['email'];$mensaje = $_POST['mensaje'];$pattern = '/[^0-9]/';if(empty($nombre) || empty($telefono) || empty($email)){$errormsg.= "<p style=\"color: red;\">Rellene todos los campos.</p>";}if(!$email == "" && (!strstr($email,"@") || !strstr($email,"."))){$errormsg.= "<p style=\"color: red;\">Ingrese una direccion de e-mail válida.</p>";}if (empty($_POST['mensaje'])){$errormsg.= "<p style=\"color: red;\">Rellene todas las casillas.</p>";}if (preg_match($pattern, $telefono)){$errormsg.= "<p style=\"color: red;\">El numero de telefono no es valido.</p>";}$para = 'mymail@mail.com';$asunto = 'Contacto desde pagina web';$header = 'From: ' . $email . " rn";$emailcontent = "Este mensaje fue enviado por: " . $nombre . " ";$emailcontent .= "Su telefono es: " . $telefono . " ";$emailcontent .= "Su e-mail es: " . $email . " ";$emailcontent .= "Mensaje: " . $_POST['mensaje'] . " " ;$emailcontent .= "Enviado el " . date('d/m/Y', time());//----------------------------------------------------if($errormsg == "") // if no errors found, send email go to page.... (this should be at end, below all validation conditions){mail($para, $asunto, utf8_decode($emailcontent), $headers); //Note change '$mensaje' to $emailcontent$errormsg="<p style=\"color: #009afc;\"> Gracias, su mensaje ha sido enviado.</p>";$nombre = "";$telefono = "";$email = "";$mensaje = "";}} ?> Link to comment Share on other sites More sharing options...
justsomeguy Posted August 21, 2009 Share Posted August 21, 2009 If it actually says "rn", that's not correct, it should be "\r\n". Link to comment Share on other sites More sharing options...
shoyle Posted August 22, 2009 Author Share Posted August 22, 2009 m still exactly the same, more than worring about the people knowing my hosting company its because you cant click reply and reply to the persons e-mail. any other ideas? Link to comment Share on other sites More sharing options...
dsonesuk Posted August 22, 2009 Share Posted August 22, 2009 did you enclose it angled brackets as in the example's i provided<matthew@example.com> but as$mensaje .= "Su e-mail es: <".$email.">"; Link to comment Share on other sites More sharing options...
shoyle Posted August 24, 2009 Author Share Posted August 24, 2009 maybe it has to do with the order of the centences? Link to comment Share on other sites More sharing options...
justsomeguy Posted August 24, 2009 Share Posted August 24, 2009 Did you ask your host about it? If their email server is only set up to send out email from the domains that are hosted on the server then it doesn't matter what the code looks like. Link to comment Share on other sites More sharing options...
shoyle Posted August 27, 2009 Author Share Posted August 27, 2009 the hosting is ok, and It use to show the e-mail of the person but it doesnt since I started to make changes when I asked on this forum, there must be some tiny part thats wrong Link to comment Share on other sites More sharing options...
justsomeguy Posted August 27, 2009 Share Posted August 27, 2009 $header = 'From: ' . $email . " rn";...mail($para, $asunto, utf8_decode($emailcontent), $headers); Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.