Jump to content

Urgent Help!


shoyle
 Share

Recommended Posts

Hi everyone, I'm having a problem on my contact form and I really need to get this done by today or the owners of the page will chew me and cancel the site and oviously that leaves me out of work, im very new on this stuff and i really need somebodies help urgently, they say that when you send the e-mails they receive them but not all the information comes. I will apreciate lots any help please!!!

<?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 = 'email@hotmail.com';$asunto = 'Contacto desde pagina web'; $header = 'From: ' . $email . " rn";mail($para, $asunto, utf8_decode($emailcontent), $headers);$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 = "";//header("Location: [url="http://www.laradialautomoviles.com/gracias.html&quot%3b%29;"]http://www.laradialautomoviles.com/gracias.html");[/url]} ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="shortcut icon" href="http://www.laradialautomoviles.com/favicon.gif"><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>.: La Radial Automoviles - Contacto :.</title><style type="text/css"><!--body {	background-image: url(images/rayas.gif);	background-color: #FFFFFF;}a:link {	color: #15BCFB;	text-decoration: none;}a:visited {	color: #0679B0;	text-decoration: none;}a:hover {	color: #2495F0;	text-decoration: none;}a:active {	color: #666666;	text-decoration: none;}.Estilo21 {font-family: Calibri}.Estilo22 {	font-family: Calibri;	font-size: 24px;	color: #2BAAFF;}.Estilo23 {	color: #000000;	font-size: 12;}--></style><script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script><script type="text/javascript"><!--function MM_findObj(n, d) { //v4.01var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);if(!x && d.getElementById) x=d.getElementById(n); return x;}function MM_preloadImages() { //v3.0var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}}function MM_swapImgRestore() { //v3.0var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;}function MM_swapImage() { //v3.0var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}}//--></script></head><body onload="MM_preloadImages('images/larradial_08.gif','images/larradial_09.gif','images/larradial_10.gif','images/larradial_11.gif','images/larradial_12.gif','images/la-BUENA-2_06.gif','images/la-BUENA-2_07.gif','images/la-BUENA-2_08.gif','images/la-BUENA-2_09.gif','images/la-BUENA-2_10.gif')" topmargin="0"><table width="200" border="0" align="center" cellpadding="0" cellspacing="0" background="images/rayas.gif"><tr><td height="89"><img src="images/la-BUENA_03.gif" width="763" height="196" /></td></tr><tr><td height="272"><script type="text/javascript">AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width','763','height','272','src','slide','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movie','slide' ); //end AC code</script><noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="763" height="272"><param name="movie" value="slide.swf" /><param name="quality" value="high" /><embed src="slide.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="763" height="272"></embed></object></noscript>  </td></tr><tr><td height="37"><a href="index.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image2','','images/la-BUENA-2_06.gif',1)"><img src="images/la-BUENA_06.gif" name="Image2" width="101" height="72" border="0" id="Image2" /></a><a href="vehiculos-nuevos.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image3','','images/la-BUENA-2_07.gif',1)"><img src="images/la-BUENA_07.gif" name="Image3" width="192" height="72" border="0" id="Image3" /></a><a href="vehiculos-usados.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image4','','images/la-BUENA-2_08.gif',1)"><img src="images/la-BUENA_08.gif" name="Image4" width="180" height="72" border="0" id="Image4" /></a><a href="nuestro-equipo.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image5','','images/la-BUENA-2_09.gif',1)"><img src="images/la-BUENA_09.gif" name="Image5" width="171" height="72" border="0" id="Image5" /></a><a href="contacto.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image6','','images/la-BUENA-2_10.gif',1)"><img src="images/la-BUENA_10.gif" name="Image6" width="119" height="72" border="0" id="Image6" /></a></td></tr><tr><td height="500" background="images/bak.gif"><table width="762" height="500" border="0" cellpadding="0" cellspacing="0">      <td ><p> </p>        <table width="703" height="513" border="0" align="center" cellpadding="0" cellspacing="0">          <tr>            <td height="35" align="center"><img src="images/sucursales.gif" width="703" height="50" /></td>          </tr>          <tr>            <td><table width="686" height="741" border="0" align="center" cellpadding="0" cellspacing="0">              <tr>                <th height="22" colspan="2" scope="row"> </th>              </tr>              <tr>                <th width="347" height="110" scope="row"><img src="Cars/DSC09027.JPG" width="290" height="218" /></th>                <th width="339" scope="row"><img src="Cars/DSC09114.JPG" width="290" height="218" /></th>              </tr>              <tr>                <th height="111" scope="row"><table width="285" height="93" border="0" align="center" cellpadding="0" cellspacing="0">                  <tr>                    <td height="10"></td>                  </tr>                  <tr>                    <th scope="row"><span class="Estilo22">Nueva Helvecia </span><br />                      <span class="Estilo21">Avda Batlle y Ordoñez s/n </span><br />                      <span class="Estilo21">Tel: (055)46360/61</span></th>                  </tr>                  <tr>                    <td height="30"></td>                  </tr>                </table></th>                <th width="339" scope="row"><table width="262" height="92" border="0" align="center" cellpadding="0" cellspacing="0">                  <tr>                    <th height="10" scope="row"> </th>                  </tr>                  <tr>                    <th colspan="2" scope="row"> <span class="Estilo22">Colonia Valdense</span><br/>                      <span class="Estilo21"> Ruta 1 Km 120 </span><br/>                   <span class="Estilo21"> Tel: (055)89838.</span></th></tr>                  <tr>                    <td height="30"></td>                  </tr>                </table></th>              </tr>              <tr>                <th height="19" colspan="2" scope="row"> </th>              </tr>              <tr>                <th height="57" colspan="2" scope="row"><table width="262" height="135" border="0" align="center" cellpadding="0" cellspacing="0">                  <tr>                    <th scope="row"><img src="Cars/DSC09179.JPG" width="290" height="218" /></th>                  </tr>                  <tr>                    <th scope="row"><table width="288" height="10" border="0" align="center" cellpadding="0" cellspacing="0">                      <tr>                      </tr>                    </table></th>                  </tr>                  <tr>                      <th scope="row"><span class="Estilo22">San José</span><br/>                         <span class="Estilo21">José Pedro Varela y Manuel de Rodriguez</span><br/>							<span class="Estilo21">Tel: (034)31440</span></th>                  </tr>                  <tr>                    <td height="30"></td>                  </tr>                </table></th>              </tr>              <tr>                <th height="19" colspan="2" scope="row"> </th>              </tr>              <tr>                <th height="29" colspan="2" scope="row"><table width="400" height="76" border="0" align="center" cellpadding="0" cellspacing="0">                  <tr>                    <th width="400" scope="row"> </th>                  </tr>                  <tr>                    <th scope="row"><p class="Estilo22">O contáctenos a través de nuestro sitio</p></th>                  </tr>                  <tr>                    <th scope="row"><table width="100" border="0" align="center" cellpadding="0" cellspacing="0">                      <tr>                        <td> </td>                      </tr>                      <tr>                        <td><tr></td>                      </tr>                      <tr>                        <td><td></td>                      </tr><tr><td><table width="100" border="0" align="center" cellpadding="0" cellspacing="0"><tr><td> </td></tr><tr><td><?php echo $errormsg; ?><form action="contacto.php" method="post" target="_self"><div align="center"><span class="Estilo21">Nombre:</span><br/><input type="text" name="nombre" value="<?php echo $nombre ?>" /><br/><br/><span class="Estilo21">Teléfono:</span><br/><input type="text" name="telefono" value="<?php echo $telefono ?>" /><br/><br/><span class="Estilo21">E-mail:</span><br/><input type="text" name="email" value="<?php echo $email ?>" /><br/><br/><span class="Estilo21">Mensaje:</span><br/><textarea rows="10" cols="50" name="mensaje"><?php echo $mensaje ?></textarea><br/><br/><input type="image" name="submit" src="images/enviar.gif" border="0" /></div></form></td></tr></table></td></tr></table></td></tr><tr><td height="62"><a href="http://www.pumsho.com"><img src="images/la-BUENA_13.gif" width="763" height="62" border="0"/></a></td></tr></table></body></html> 

Link to comment
Share on other sites

Well, what is the problem?

Link to comment
Share on other sites

A few weird things, which may or may not be causing your problem:if(!$email == "" && (!strstr($email,"@") || !strstr($email,".")))!$email == "" is an odd thing to say. Try $email != ""There are other ways of validating an email address, which are easier: if(filter_var($email], FILTER_VALIDATE_EMAIL)) will only return TRUE in the event that the email address is valid (but of course it doesn't check that it is real).That only works if you have filters set up in your configuration. If not, try:if($email != "" && preg_match("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", strtolower($email))) Note that I nicked the regex from a tutorial site - it may or may not work! Give it a shot.

Link to comment
Share on other sites

A few weird things, which may or may not be causing your problem:if(!$email == "" && (!strstr($email,"@") || !strstr($email,".")))!$email == "" is an odd thing to say. Try $email != ""There are other ways of validating an email address, which are easier: if(filter_var($email], FILTER_VALIDATE_EMAIL)) will only return TRUE in the event that the email address is valid (but of course it doesn't check that it is real).That only works if you have filters set up in your configuration. If not, try:if($email != "" && preg_match("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", strtolower($email))) Note that I nicked the regex from a tutorial site - it may or may not work! Give it a shot.
the thing is that white i write on the message box comes up, but the email of the person, the name or the phone (3 things that u enter on the boxes) dont come up on the email u receive, there must be a problem on the header and $emailcontent part
Link to comment
Share on other sites

the thing is that white i write on the message box comes up, but the email of the person, the name or the phone (3 things that u enter on the boxes) dont come up on the email u receive, there must be a problem on the header and $emailcontent part
another problem is that when you enter the site it allready says thanks your mesage wass succsesfully sent (gracias su mensaje ha sido enviado correctamente). in case u wanna chek the site is www.laradialautomoviles.com/contacto.php
Link to comment
Share on other sites

If you want to pre-populate the form fields when a user first comes to the page, then you would want to set the values of the of the form elements. If you want them to remain after they filled out the form, but say if they made an error, google sticky forms. As far as the thank you message, that might be an issue with the logic/code as pointed out by chibineku.

Edited by thescientist
Link to comment
Share on other sites

Look at this part:

$header = 'From: ' . $email . " rn";mail($para, $asunto, utf8_decode($emailcontent), $headers);$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());

You set the header, then send the mail, then build the text. You need to build the text before you send the mail, not after. You're also using both "$header" and "$headers", make sure you're consistent.Also, headers need to end with "\r\n", not "rn". If you want to separate the lines in the email body, you can use "\n" to add a line break into the email text.

Link to comment
Share on other sites

Here is my code now, it still doesnt work it sends a message when u enter the cntact page, and the mesage apears followed by the email and phone and name of the person and the mesage repeated again. please help!!!!

<?php$nombre = "";$telefono = "";$email = "";$emailcontent = "";$errormsg = "";if (isset($_POST['nombre']) || isset($_POST['telefono']) || isset($_POST['email'])){$nombre = $_POST['nombre'];$telefono = $_POST['telefono'];$email = $_POST['email'];$emailcontent = $_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>";}$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());}$para = 'stinky355@hotmail.com';$asunto = 'Contacto desde pagina web'; $header = 'From: ' . $email . "\r\n";mail($para, $asunto, utf8_decode($emailcontent), $headers);//----------------------------------------------------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 = "";$emailcontent = "";//header("Location: [url="http://www.laradialautomoviles.com/gracias.html&quot%3b%29;"]http://www.laradialautomoviles.com/gracias.html");[/url]} ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="shortcut icon" href="http://www.laradialautomoviles.com/favicon.gif"><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>.: La Radial Automoviles - Contacto :.</title><style type="text/css"><!--body {	background-image: url(images/rayas.gif);	background-color: #FFFFFF;}a:link {	color: #15BCFB;	text-decoration: none;}a:visited {	color: #0679B0;	text-decoration: none;}a:hover {	color: #2495F0;	text-decoration: none;}a:active {	color: #666666;	text-decoration: none;}.Estilo21 {font-family: Calibri}.Estilo22 {	font-family: Calibri;	font-size: 24px;	color: #2BAAFF;}.Estilo23 {	color: #000000;	font-size: 12;}--></style><script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script><script type="text/javascript"><!--function MM_findObj(n, d) { //v4.01var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);if(!x && d.getElementById) x=d.getElementById(n); return x;}function MM_preloadImages() { //v3.0var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}}function MM_swapImgRestore() { //v3.0var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;}function MM_swapImage() { //v3.0var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}}//--></script></head><body onload="MM_preloadImages('images/larradial_08.gif','images/larradial_09.gif','images/larradial_10.gif','images/larradial_11.gif','images/larradial_12.gif','images/la-BUENA-2_06.gif','images/la-BUENA-2_07.gif','images/la-BUENA-2_08.gif','images/la-BUENA-2_09.gif','images/la-BUENA-2_10.gif')" topmargin="0"><table width="200" border="0" align="center" cellpadding="0" cellspacing="0" background="images/rayas.gif"><tr><td height="89"><img src="images/la-BUENA_03.gif" width="763" height="196" /></td></tr><tr><td height="272"><script type="text/javascript">AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width','763','height','272','src','slide','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movie','slide' ); //end AC code</script><noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="763" height="272"><param name="movie" value="slide.swf" /><param name="quality" value="high" /><embed src="slide.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="763" height="272"></embed></object></noscript>  </td></tr><tr><td height="37"><a href="index.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image2','','images/la-BUENA-2_06.gif',1)"><img src="images/la-BUENA_06.gif" name="Image2" width="101" height="72" border="0" id="Image2" /></a><a href="vehiculos-nuevos.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image3','','images/la-BUENA-2_07.gif',1)"><img src="images/la-BUENA_07.gif" name="Image3" width="192" height="72" border="0" id="Image3" /></a><a href="vehiculos-usados.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image4','','images/la-BUENA-2_08.gif',1)"><img src="images/la-BUENA_08.gif" name="Image4" width="180" height="72" border="0" id="Image4" /></a><a href="nuestro-equipo.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image5','','images/la-BUENA-2_09.gif',1)"><img src="images/la-BUENA_09.gif" name="Image5" width="171" height="72" border="0" id="Image5" /></a><a href="contacto.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image6','','images/la-BUENA-2_10.gif',1)"><img src="images/la-BUENA_10.gif" name="Image6" width="119" height="72" border="0" id="Image6" /></a></td></tr><tr><td height="500" background="images/bak.gif"><table width="762" height="500" border="0" cellpadding="0" cellspacing="0">      <td ><p> </p>        <table width="703" height="513" border="0" align="center" cellpadding="0" cellspacing="0">          <tr>            <td height="35" align="center"><img src="images/sucursales.gif" width="703" height="50" /></td>          </tr>          <tr>            <td><table width="686" height="741" border="0" align="center" cellpadding="0" cellspacing="0">              <tr>                <th height="22" colspan="2" scope="row"> </th>              </tr>              <tr>                <th width="347" height="110" scope="row"><img src="Cars/DSC09027.JPG" width="290" height="218" /></th>                <th width="339" scope="row"><img src="Cars/DSC09114.JPG" width="290" height="218" /></th>              </tr>              <tr>                <th height="111" scope="row"><table width="285" height="93" border="0" align="center" cellpadding="0" cellspacing="0">                  <tr>                    <td height="10"></td>                  </tr>                  <tr>                    <th scope="row"><span class="Estilo22">Nueva Helvecia </span><br />                      <span class="Estilo21">Avda Batlle y Ordoñez s/n </span><br />                      <span class="Estilo21">Tel: (055)46360/61</span></th>                  </tr>                  <tr>                    <td height="30"></td>                  </tr>                </table></th>                <th width="339" scope="row"><table width="262" height="92" border="0" align="center" cellpadding="0" cellspacing="0">                  <tr>                    <th height="10" scope="row"> </th>                  </tr>                  <tr>                    <th colspan="2" scope="row"> <span class="Estilo22">Colonia Valdense</span><br/>                      <span class="Estilo21"> Ruta 1 Km 120 </span><br/>                   <span class="Estilo21"> Tel: (055)89838.</span></th></tr>                  <tr>                    <td height="30"></td>                  </tr>                </table></th>              </tr>              <tr>                <th height="19" colspan="2" scope="row"> </th>              </tr>              <tr>                <th height="57" colspan="2" scope="row"><table width="262" height="135" border="0" align="center" cellpadding="0" cellspacing="0">                  <tr>                    <th scope="row"><img src="Cars/DSC09179.JPG" width="290" height="218" /></th>                  </tr>                  <tr>                    <th scope="row"><table width="288" height="10" border="0" align="center" cellpadding="0" cellspacing="0">                      <tr>                      </tr>                    </table></th>                  </tr>                  <tr>                      <th scope="row"><span class="Estilo22">San José</span><br/>                         <span class="Estilo21">José Pedro Varela y Manuel de Rodriguez</span><br/>							<span class="Estilo21">Tel: (034)31440</span></th>                  </tr>                  <tr>                    <td height="30"></td>                  </tr>                </table></th>              </tr>              <tr>                <th height="19" colspan="2" scope="row"> </th>              </tr>              <tr>                <th height="29" colspan="2" scope="row"><table width="400" height="76" border="0" align="center" cellpadding="0" cellspacing="0">                  <tr>                    <th width="400" scope="row"> </th>                  </tr>                  <tr>                    <th scope="row"><p class="Estilo22">O contáctenos a través de nuestro sitio</p></th>                  </tr>                  <tr>                    <th scope="row"><table width="100" border="0" align="center" cellpadding="0" cellspacing="0">                      <tr>                        <td> </td>                      </tr>                      <tr>                        <td><tr></td>                      </tr>                      <tr>                        <td><td></td>                      </tr><tr><td><table width="100" border="0" align="center" cellpadding="0" cellspacing="0"><tr><td> </td></tr><tr><td><?php echo $errormsg; ?><form action="contacto.php" method="post" target="_self"><div align="center"><span class="Estilo21">Nombre:</span><br/><input type="text" name="nombre" value="<?php echo $nombre ?>" /><br/><br/><span class="Estilo21">Teléfono:</span><br/><input type="text" name="telefono" value="<?php echo $telefono ?>" /><br/><br/><span class="Estilo21">E-mail:</span><br/><input type="text" name="email" value="<?php echo $email ?>" /><br/><br/><span class="Estilo21">Mensaje:</span><br/><textarea rows="10" cols="50" name="mensaje"><?php echo $mensaje ?></textarea><br/><br/><input type="image" name="submit" src="images/enviar.gif" border="0" /></div></form></td></tr></table></td></tr></table></td></tr><tr><td height="62"><a href="http://www.pumsho.com"><img src="images/la-BUENA_13.gif" width="763" height="62" border="0"/></a></td></tr></table></body></html>  

Link to comment
Share on other sites

You need to move these lines:$para = 'stinky355@hotmail.com';$asunto = 'Contacto desde pagina web';$header = 'From: ' . $email . "\r\n";mail($para, $asunto, utf8_decode($emailcontent), $headers);into the if statement that checks if the form was submitted. Those lines are not in the if statement, so it will always send a mail whenever you load the page. Those need to be inside the if statement that checks if the form was submitted, and you'll need to add another if statement around those 4 lines to check if any errors happened before it sends the mail.

Link to comment
Share on other sites

You need to move these lines:$para = 'stinky355@hotmail.com';$asunto = 'Contacto desde pagina web';$header = 'From: ' . $email . "\r\n";mail($para, $asunto, utf8_decode($emailcontent), $headers);into the if statement that checks if the form was submitted. Those lines are not in the if statement, so it will always send a mail whenever you load the page. Those need to be inside the if statement that checks if the form was submitted, and you'll need to add another if statement around those 4 lines to check if any errors happened before it sends the mail.
sorry whewre in the code is that, im not very good english speaker plus i dont know php :S
Link to comment
Share on other sites

Before this comment://----------------------------------------------------
still exactly same problem plus sends email when u enter the page, another problem is that when ypu enter the page it says thanks ur mesage was sent correctly, maybe thats another clue..
Link to comment
Share on other sites

what's your code now?
 <?php$nombre = "";$telefono = "";$email = "";$mensaje = "";$emailcontent = "";$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 = 'stinky355@hotmail.com';$asunto = 'Contacto desde pagina web';$header = 'From: ' . $email . "\r\n"; $emailcontent .= "Este mensaje fue enviado por: " . $nombre . " \n "; $emailcontent .= "Su telefono es: " . $telefono . " \n ";$emailcontent .= "Su e-mail es: " . $email . " \n ";$emailcontent .= "Mensaje: " . $_POST['mensaje'] . " \n " ;$emailcontent .= "Enviado el " . date('d/m/Y', time());}mail($para, $asunto, utf8_decode($emailcontent), $headers);//----------------------------------------------------if($errormsg == "") {$errormsg="<p style=\"color: #009afc;\"> Gracias, su mensaje ha sido enviado.</p>";$nombre = "";$telefono = "";$email = "";$mensaje = "";}//header("Location: [url="http://www.laradialautomoviles.com/gracias.html&quot%3b%29;"]http://www.laradialautomoviles.com/gracias.html");[/url]//mail($para, $asunto, utf8_decode($emailcontent), $headers); //Note change '$mensaje' to $emailcontent// if no errors found, send email go to page.... (this should be at end, below all validation conditions) ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="shortcut icon" href="http://www.laradialautomoviles.com/favicon.gif"><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>.: La Radial Automoviles - Contacto :.</title><style type="text/css"><!--body {	background-image: url(images/rayas.gif);	background-color: #FFFFFF;}a:link {	color: #15BCFB;	text-decoration: none;}a:visited {	color: #0679B0;	text-decoration: none;}a:hover {	color: #2495F0;	text-decoration: none;}a:active {	color: #666666;	text-decoration: none;}.Estilo21 {font-family: Calibri}.Estilo22 {	font-family: Calibri;	font-size: 24px;	color: #2BAAFF;}.Estilo23 {	color: #000000;	font-size: 12;}--></style><script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script><script type="text/javascript"><!--function MM_findObj(n, d) { //v4.01var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);if(!x && d.getElementById) x=d.getElementById(n); return x;}function MM_preloadImages() { //v3.0var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}}function MM_swapImgRestore() { //v3.0var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;}function MM_swapImage() { //v3.0var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}}//--></script></head><body onload="MM_preloadImages('images/larradial_08.gif','images/larradial_09.gif','images/larradial_10.gif','images/larradial_11.gif','images/larradial_12.gif','images/la-BUENA-2_06.gif','images/la-BUENA-2_07.gif','images/la-BUENA-2_08.gif','images/la-BUENA-2_09.gif','images/la-BUENA-2_10.gif')" topmargin="0"><table width="200" border="0" align="center" cellpadding="0" cellspacing="0" background="images/rayas.gif"><tr><td height="89"><img src="images/la-BUENA_03.gif" width="763" height="196" /></td></tr><tr><td height="272"><script type="text/javascript">AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width','763','height','272','src','slide','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movie','slide' ); //end AC code</script><noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="763" height="272"><param name="movie" value="slide.swf" /><param name="quality" value="high" /><embed src="slide.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="763" height="272"></embed></object></noscript>  </td></tr><tr><td height="37"><a href="index.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image2','','images/la-BUENA-2_06.gif',1)"><img src="images/la-BUENA_06.gif" name="Image2" width="101" height="72" border="0" id="Image2" /></a><a href="vehiculos-nuevos.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image3','','images/la-BUENA-2_07.gif',1)"><img src="images/la-BUENA_07.gif" name="Image3" width="192" height="72" border="0" id="Image3" /></a><a href="vehiculos-usados.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image4','','images/la-BUENA-2_08.gif',1)"><img src="images/la-BUENA_08.gif" name="Image4" width="180" height="72" border="0" id="Image4" /></a><a href="nuestro-equipo.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image5','','images/la-BUENA-2_09.gif',1)"><img src="images/la-BUENA_09.gif" name="Image5" width="171" height="72" border="0" id="Image5" /></a><a href="contacto.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image6','','images/la-BUENA-2_10.gif',1)"><img src="images/la-BUENA_10.gif" name="Image6" width="119" height="72" border="0" id="Image6" /></a></td></tr><tr><td height="500" background="images/bak.gif"><table width="762" height="500" border="0" cellpadding="0" cellspacing="0">      <td ><p> </p>        <table width="703" height="513" border="0" align="center" cellpadding="0" cellspacing="0">          <tr>            <td height="35" align="center"><img src="images/sucursales.gif" width="703" height="50" /></td>          </tr>          <tr>            <td><table width="686" height="741" border="0" align="center" cellpadding="0" cellspacing="0">              <tr>                <th height="22" colspan="2" scope="row"> </th>              </tr>              <tr>                <th width="347" height="110" scope="row"><img src="Cars/DSC09027.JPG" width="290" height="218" /></th>                <th width="339" scope="row"><img src="Cars/DSC09114.JPG" width="290" height="218" /></th>              </tr>              <tr>                <th height="111" scope="row"><table width="285" height="93" border="0" align="center" cellpadding="0" cellspacing="0">                  <tr>                    <td height="10"></td>                  </tr>                  <tr>                    <th scope="row"><span class="Estilo22">Nueva Helvecia </span><br />                      <span class="Estilo21">Avda Batlle y Ordoñez s/n </span><br />                      <span class="Estilo21">Tel: (055)46360/61</span></th>                  </tr>                  <tr>                    <td height="30"></td>                  </tr>                </table></th>                <th width="339" scope="row"><table width="262" height="92" border="0" align="center" cellpadding="0" cellspacing="0">                  <tr>                    <th height="10" scope="row"> </th>                  </tr>                  <tr>                    <th colspan="2" scope="row"> <span class="Estilo22">Colonia Valdense</span><br/>                      <span class="Estilo21"> Ruta 1 Km 120 </span><br/>                   <span class="Estilo21"> Tel: (055)89838.</span></th></tr>                  <tr>                    <td height="30"></td>                  </tr>                </table></th>              </tr>              <tr>                <th height="19" colspan="2" scope="row"> </th>              </tr>              <tr>                <th height="57" colspan="2" scope="row"><table width="262" height="135" border="0" align="center" cellpadding="0" cellspacing="0">                  <tr>                    <th scope="row"><img src="Cars/DSC09179.JPG" width="290" height="218" /></th>                  </tr>                  <tr>                    <th scope="row"><table width="288" height="10" border="0" align="center" cellpadding="0" cellspacing="0">                      <tr>                      </tr>                    </table></th>                  </tr>                  <tr>                      <th scope="row"><span class="Estilo22">San José</span><br/>                         <span class="Estilo21">José Pedro Varela y Manuel de Rodriguez</span><br/>							<span class="Estilo21">Tel: (034)31440</span></th>                  </tr>                  <tr>                    <td height="30"></td>                  </tr>                </table></th>              </tr>              <tr>                <th height="19" colspan="2" scope="row"> </th>              </tr>              <tr>                <th height="29" colspan="2" scope="row"><table width="400" height="76" border="0" align="center" cellpadding="0" cellspacing="0">                  <tr>                    <th width="400" scope="row"> </th>                  </tr>                  <tr>                    <th scope="row"><p class="Estilo22">O contáctenos a través de nuestro sitio</p></th>                  </tr>                  <tr>                    <th scope="row"><table width="100" border="0" align="center" cellpadding="0" cellspacing="0">                      <tr>                        <td> </td>                      </tr>                      <tr>                        <td><tr></td>                      </tr>                      <tr>                        <td><td></td>                      </tr><tr><td><table width="100" border="0" align="center" cellpadding="0" cellspacing="0"><tr><td> </td></tr><tr><td><?php echo $errormsg; ?><form action="contacto.php" method="post" target="_self"><div align="center"><span class="Estilo21">Nombre:</span><br/><input type="text" name="nombre" value="<?php echo $nombre ?>" /><br/><br/><span class="Estilo21">Teléfono:</span><br/><input type="text" name="telefono" value="<?php echo $telefono ?>" /><br/><br/><span class="Estilo21">E-mail:</span><br/><input type="text" name="email" value="<?php echo $email ?>" /><br/><br/><span class="Estilo21">Mensaje:</span><br/><textarea rows="10" cols="50" name="mensaje"><?php echo $mensaje ?></textarea><br/><br/><input type="image" name="submit" src="images/enviar.gif" border="0" /></div></form></td></tr></table></td></tr></table></td></tr><tr><td height="62"><a href="http://www.pumsho.com"><img src="images/la-BUENA_13.gif" width="763" height="62" border="0"/></a></td></tr></table></body></html>  

the problem now is that it gives you the thank you when u enter, before u send the mesage, i fixed the other problems

Link to comment
Share on other sites

I think you're logic is a little wonky, it could be in the implementation of all those if statements. It should be as simple as:1) when the form is submitted (start of if statement) --> validation: check that variables have been entered into the form (w/(isset)) --> send the message --> display the thank you message2) else --> display an error message

Edited by thescientist
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...