Foros del Web » Programando para Internet » PHP »

Ayuda Con Formulario Web Please

Estas en el tema de Ayuda Con Formulario Web Please en el foro de PHP en Foros del Web. Hola a todos. No tengo mucho tiempo asi que lo voy a tratar de hacer lo mas corto y entendible posible. Estoy ayudando a un ...
  #1 (permalink)  
Antiguo 27/05/2010, 22:33
Avatar de NnikoO  
Fecha de Ingreso: agosto-2008
Ubicación: Rosario
Mensajes: 245
Antigüedad: 15 años, 8 meses
Puntos: 0
Exclamación Ayuda Con Formulario Web Please

Hola a todos. No tengo mucho tiempo asi que lo voy a tratar de hacer lo mas corto y entendible posible. Estoy ayudando a un amigo con una pagina, que contiene un formulario de contacto, la verdad hace siglos que no configuro uno de estos con php, y pense que me acordaba, y la verdad, no, jejejeje estoy en bolas.

El servidor me toma perfecto el codigo, lleno el formulario, envio, me tira el mensaje de que fue enviado, todo lindo y perfecto. Pero, el mail nunca llega. Dejo los codigos para que me puedan ayudar.


Contacto.php (pagina que contiene el formulario):

Código PHP:
<?
 
if (isset($_POST['enviar']))
 {
  if(
$_POST['nombre'] == "")
  {
   
$mensaje "<strong>Debe completar su nombre y apellido.</strong>";
  }
  elseif(
$_POST['telefono'] == "")
  {
   
$mensaje "<strong>Debe completar su numero de telefono.</strong>";
  }
  elseif(
$_POST['horario'] == "")
  {
   
$mensaje "<strong>Debe completar su horario de contacto.</strong>";
  } 
   elseif (!
eregi("^[_.0-9a-z-]+@([0-9a-z][0-9a-z-]+.)+[a-z]{2,6}$",$mail)) 
  {
        
$mensaje "<strong>Direccion de correo electronico invalida.</strong>";
  }
  elseif(
$_POST['comentario'] == "")
  {
   
$mensaje "<strong><br>      Debes completar tu comentario.</strong>";
  }
   else
  {
        
$msjok "";
        
  }  
}
?>
<head>
</head>

<body onload="MM_preloadImages('imagenes/catalogoactivo.jpg','imagenes/materialesactivo.jpg','imagenes/compraractivo.jpg','imagenes/preguntasactivo.jpg','imagenes/contactoactivo.jpg','imagenes/morochasactivo.jpg')">
<br />
<table width="935" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="190" colspan="8" background="imagenes/cabeceracontacto.jpg">&nbsp;</td>
  </tr>
  <tr>
    <td width="163" height="70" background="imagenes/logo2.jpg">&nbsp;</td>
    <td width="82">&nbsp;</td>
    <td width="115"><a href="morochas.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Morochas','','imagenes/morochasactivo.jpg',1)"><img src="imagenes/morochas.jpg" name="Morochas" width="115" height="41" border="0" id="Morochas" /></a></td>
    <td width="115"><a href="catalogo.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Catalogo','','imagenes/catalogoactivo.jpg',1)"><img src="imagenes/catalogo.jpg" name="Catalogo" width="115" height="41" border="0" id="Catalogo" /></a></td>
    <td width="115"><a href="materiales.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Materiales','','imagenes/materialesactivo.jpg',1)"><img src="imagenes/materiales.jpg" name="Materiales" width="115" height="41" border="0" id="Materiales" /></a></td>
    <td width="115"><a href="comprar.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Comprar','','imagenes/compraractivo.jpg',1)"><img src="imagenes/comprar.jpg" name="Comprar" width="115" height="41" border="0" id="Comprar" /></a></td>
    <td width="115"><a href="preguntas.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Preguntas','','imagenes/preguntasactivo.jpg',1)"></a><a href="preguntas.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Preguntas','','imagenes/preguntasactivo.jpg',1)"><img src="imagenes/preguntas.jpg" name="Preguntas" width="115" height="41" border="0" id="Preguntas" /></a></td>
    <td width="115"><a href="contacto.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Contacto','','imagenes/contactoactivo.jpg',1)"><img src="imagenes/contactoactivo.jpg" width="115" height="41" border="0" /></a></td>
  </tr>
  <tr>
    <td height="200" colspan="8"><a href="Catálogo/1.jpg" rel="lytebox[vacation]" title="INFO"></a>
      <a href="Catálogo/2.jpg" rel="lytebox[vacation]" title="INFO"></a>
      <a href="Catálogo/4.jpg" rel="lytebox[vacation]" title="INFO"></a>
      <a href="Catálogo/3.jpg" rel="lytebox[vacation]" title="INFO"></a>
      <a href="Catálogo/5.jpg" rel="lytebox[vacation]" title="INFO"></a>
      <a href="Catálogo/6.jpg" rel="lytebox[vacation]" title="INFO"></a>
      <a href="Catálogo/7.jpg" rel="lytebox[vacation]" title="INFO"></a>
      <p align="justify" class="Estilo31"><span class="Estilo33">&macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; </span> <span class="Estilo34">&macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; <span class="Estilo35">&macr; </span>&macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr; &macr;</span> <span class="Estilo34">&macr;</span><br />
        <br />
      </p>
      <form id="form1" name="form1" method="post" action="enviar.php">
        <? if(!isset($msjok)){ ?>
        <table width="395" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td width="148"><span class="Estilo41">Nombre y apellido </span></td>
            <td width="197"><label>
              <input name="nombre" type="text" size="30" />
              </label>            </td>
            <td width="36">&nbsp;</td>
          </tr>
          <tr>
            <td><span class="Estilo41">Tel&eacute;fono </span></td>
            <td><label>
              <input name="telefono" type="text" size="30" />
              </label>            </td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td><span class="Estilo41">Horario de contacto </span></td>
            <td><label>
              <input name="horario" type="text" size="30" />
              </label>            </td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td><span class="Estilo41">E-mail</span></td>
            <td><label>
              <input name="mail" type="text" size="30" />
              </label>            </td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td><span class="Estilo41">Comentario</span></td>
            <td><label>
              <textarea name="comentario" cols="23"></textarea>
              </label>
                <br />
                <p>
                  <input type="submit" name="enviar" value="Enviar" />
                  <input type="reset" name="restablecer" value="Restablecer" />
              </p></td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td height="49">&nbsp;</td>
            <td><table width="200" border="0" align="center" cellpadding="0" cellspacing="0">
              <tr>
                <td><span class="Estilo1">
                  <?= $mensaje?>
                </span></td>
              </tr>
            </table></td>
            <td>&nbsp;</td>
          </tr>
        </table>
            </form>
      <p align="justify" class="Estilo31">_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
        <? }else{ 
                    echo 
$msjok ;
                    require(
"enviar.php");                                                                      
        } 
?> 
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ __</p>    </td>
  </tr>
  <tr>
    <td height="30" colspan="8"><div align="center"><span class="Estilo5"><span class="Estilo15"><span class="Estilo18"><span class="Estilo25">&copy; 2010</span> <span class="Estilo38">Morochas Shoes</span> <span class="Estilo25">:.&nbsp; Rosario, Santa Fe, Argentina&nbsp;&nbsp;:&nbsp; Tel. + 54 (341) 155 919463 &nbsp;:&nbsp; [email protected] &nbsp;:
    &nbsp;Dise&ntilde;o Web: </span></span></span><span class="Estilo26"><span class="Estilo15"><span class="Estilo18"><a href="http://www.facebook.com/lisandrojofre">Lisandro Jofr&eacute;</a> .:</span></span></span></span></div></td>
  </tr>
</table>
</body>
</html>

Enviar.php (contiene la maquetacion de las variables del mail, y la funcion mail que justamente se encarga de enviarlo):

Código PHP:
<?

$cuerpo 
"Nombre y Apellido: $nombre\n
           Email: $mail\n\n
           Telefono: $telefono\n\n\n
           Horario de Contacto: $horario\n\n\n\n"
;
           
$cuerpo2 "Consulta: $comentario\n";
$dequien "$nombre";
{
mail("[email protected]","Asunto Comentario","$cuerpo $cuerpo2","from: $dequien");


echo 
"<br><table align=center><tr><td><b>Su consulta se envio correctamente. Muchas Gracias.</b></td></tr></table>"


?>
Espero que puedan ayudarme cuanto antes. Un abrazo y gracias de antemano.

<< niko >>
  #2 (permalink)  
Antiguo 27/05/2010, 22:47
Avatar de maycolalvarez
Colaborador
 
Fecha de Ingreso: julio-2008
Ubicación: Caracas
Mensajes: 12.120
Antigüedad: 15 años, 9 meses
Puntos: 1532
Respuesta: Ayuda Con Formulario Web Please

si el server es windows, necesitas instalar y configurar un SMTP
  #3 (permalink)  
Antiguo 27/05/2010, 23:47
Avatar de NnikoO  
Fecha de Ingreso: agosto-2008
Ubicación: Rosario
Mensajes: 245
Antigüedad: 15 años, 8 meses
Puntos: 0
Respuesta: Ayuda Con Formulario Web Please

Hola, gracias por responder. No, el server es Linux.
  #4 (permalink)  
Antiguo 28/05/2010, 02:24
 
Fecha de Ingreso: mayo-2010
Mensajes: 61
Antigüedad: 14 años
Puntos: 1
Respuesta: Ayuda Con Formulario Web Please

yo tambien utilizo esa funcion en mi web y yo lo hago de la siguiente manera:

to exactamente igual que tu hasta llegar a enviar.php y yo alli hago lo siguiente haber si puedo ayudarte:

$nombre=(Nombre del que quiere enviar el mensaje);
$email=(Email del que quiere enviar el mensaje);
$mensaje=(el comentario que quieres enviar en el cuerpo del mensaje);
$destinatario=(correo electronico a quien irá dirigido);

mail($destinatario, $nombre, $mensaje, "FROM: $email") or die ("Su mensaje no se envio correctamente");

yo lo tengo asi y me funciona perfectamente, tambien existe la posibilidad de que el servidor donde tengas alojada la pagina no admita la funcion mail, si es gratuita seguro que es por eso ya que se creaba mucho spam y dejaron (lamentablemente) de dar ese servicio, espero haber podido ayudar.

si pudieras echarme una mano aqui te lo agradeceria:

http://www.forosdelweb.com/f18/poner-cursor-input-text-810986/#post3420071
  #5 (permalink)  
Antiguo 28/05/2010, 18:54
Avatar de NnikoO  
Fecha de Ingreso: agosto-2008
Ubicación: Rosario
Mensajes: 245
Antigüedad: 15 años, 8 meses
Puntos: 0
Respuesta: Ayuda Con Formulario Web Please

Estuve probando pero no andubo todavia. El servidor es pago, con soporte de php.

Etiquetas: contacto, mail, mailer, smtp, formulario
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 10:04.