Ver Mensaje Individual
  #1 (permalink)  
Antiguo 14/07/2011, 05:10
arieleirin
 
Fecha de Ingreso: julio-2011
Mensajes: 1
Antigüedad: 12 años, 9 meses
Puntos: 0
Mensaje formulario de contacto

Buen Día, soy nuevo el foro, tengo un formulario de contacto i cuando se aprieta el boton de enviar, me manda a mi pàgina que deberia aparecer cuando un campo se completo de manera incorrecta.
Subo el código html + el php para vr si alguien me puede ayudar!

Formulario:
<form action="enviar php.php" method="post" id="contacto">

<label for="input_nombres">
<div align="left"><span class="Estilo13">Nombre</span></div>
</label>
<div align="left"><span class="Estilo13">
<input id="input_nombres" type="text" name="nombre" value="" />
<br />
<br />

</span></div>
<span class="Estilo13"><label for="input_apellido">
<div align="left">Apellido</div>
</label>
<div align="left">
<input id="input_apellido" type="text" name="Apellido" value="" />
<br />
<br />
</div>
<label for="input_email">
<div align="left">Email</div>
</label>
<div align="left">
<input id="input_email" type="text" name="email" value="" />
<br />
<br />
</div>
<label for="input_teléfono">
<div align="left">Teléfono</div>
</label>
<div align="left">
<input id="input_Teléfono" type="text" name="Teléfono" value="" />
<br />
<br />
</div>
<label for="input_Celular">
<div align="left">Celular</div>
</label>
<div align="left">
<input id="input_Celular" type="text" name="Celular" value="" />
<br />
<br />
</div>
<label for="textarea_mensaje">
<div align="left">Mensaje</div>
</label>
</span>
<div align="left"><span class="Estilo11"></span></div>
<span class="Estilo11"><label for="textarea_mensaje"></label>
</span>
<div align="left"><span class="Estilo9"></span></div>
<span class="Estilo9"><label for="textarea_mensaje"></label>
</span>
<div align="left"><span class="Estilo7"></span></div>
<span class="Estilo7"><label for="textarea_mensaje"></label>
</span>
<label for="textarea_mensaje"></label>
<div align="left"><br />
<textarea id="textarea_mensaje" name="mensaje" rows="5" cols="50"></textarea>
<br />
<br />

<input type="submit" name="submit" value="Enviar" />
</div>
</form>


ahora el PHP:

<?

// definimos las variables o marcamos el error
if ( !empty($_POST['nombre']) ) $nombre = $_POST['nombre']; else $error = true;
if ( !empty($_POST['apellido']) ) $apellido = $_POST['apellido']; else $error = true;
if ( !empty($_POST['email']) ) $email = $_POST['email']; else $error = true;
if ( !empty($_POST['Teléfono']) ) $Teléfono = $_POST['Teléfono']; else $error = true;
if ( !empty($_POST['Celular']) ) $Celular = $_POST['Celular']; else $error = true;

// verificamos que no exista un error
if ( !empty($error) ) {
header( 'Location: contacto_error.php' );
die;
}

// definimos el cuerpo del email
$cuerpo = "
De: $nombre \n\r
Apellido: $apellido \n\r
Email: $email \n\r
Teléfono: $Teléfono \n\r
Celular: $Celular \n\r
Mensaje: \n\r
$mensaje
";

// enviamos el email
if ( mail( '[email protected]','Recibiste un mensaje a través del formulario de contacto de tu sitio',$cuerpo ) ) {
header( 'Location: contacto_exitoso.php' );
die;
} else {
header( 'Location: contacto_error.php' );
die;
}
?>