Ver Mensaje Individual
  #6 (permalink)  
Antiguo 29/01/2015, 07:11
sx7a
 
Fecha de Ingreso: octubre-2006
Mensajes: 114
Antigüedad: 17 años, 6 meses
Puntos: 0
Respuesta: Formulario + envio

Te dejo un formulario super simple que uso, no contiene mucha verificación, después de enviar el correo te manda a una página que se llama gracias.html, créala y ponle algún mensaje del tipo gracias con una imagen. Además debes reemplazar en el archivo mailer.php tu dirección de correo donde dice "tu dirección de correo".

Esta debería ser el codigo html que debería llevar tu formulario:
Código HTML:
<form  name="formulario de contacto" action="mailer.php" method="post">

                           

                            <div >
                                <label>Nombre y Apellido<small>*</small></label>
                                <input type="text" id="name" name="name" value="" class="" />
                            </div>

                            <div class="">
                                <label for="">Email <small>*</small></label>
                                <input type="email" id="email" name="email" value="" class="" />
                            </div>

                            <div class="">
                                <label for="">Teléfono</label>
                                <input type="text" id="phone" name="phone" value="" class="" />
                            </div>

                            <div ></div>

                            <div class="">
                                <label for="">Título exacto del juego<small>*</small></label>
                                <input type="text" id="titulo" name="titulo" value="" class="" />
                            </div>

                            <div class="">
                                <label for="">Precio en dólares<small>*</small></label>
                                <input type="text" id="precio" name="precio" value="" class="" />
                            </div>
                             <div class="">
                                <label for="">¿Se encuentra el juego en oferta?<small>*</small></label>
                                <input type="checkbox" id="oferta" name="oferta" value="si"  class="" />
                            </div>

                            

                           

                            <div class="">
                                <label for="">Mensaje <small>*</small></label>
                                <textarea class="" id="message" name="message" rows="6" cols="30"></textarea>
                            </div>

                           

                            <div class="">
                                <button  type="submit" id="" name="submit" value="submit">Enviar</button>
                            </div>

                        </form> 
, y este es el archivo mailer.php

Código PHP:
<?php
/* Set e-mail recipient */
$myemail "tu direccion de correo";

/* Check all form inputs using check_input function */
$name check_input($_POST['name'], "Error en nombre");
$service check_input($_POST['titulo'], "Error en el título*");
$email check_input($_POST['email']);
$phone check_input($_POST['phone']);
$titulo check_input($_POST['titulo']);
$precio check_input($_POST['precio']);
$oferta check_input($_POST['oferta']);
$message check_input($_POST['message'], "Error en mensaje");

/* If e-mail is not valid show error message */
if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/"$email))
{
show_error("Por favor ingrese una dirección válida");
}
/* Let's prepare the message for the e-mail */
$message "

Nombre: $name
E-mail: $email
Teléfono: $phone
Titulo: $service
precio: $precio
oferta: $oferta

Mensaje:
$message

"
;

/* Send the message using mail() function */
mail($myemail$service$message);

/* Redirect visitor to the thank you page */
header('Location: gracias.html');
exit();

/* Functions we used */
function check_input($data$problem='')
{
$data trim($data);
$data stripslashes($data);
$data htmlspecialchars($data);
if (
$problem && strlen($data) == 0)
{
show_error($problem);
}
return 
$data;
}

function 
show_error($myError)
{
?>
<html>
<body>

<p>Por favor, verifique sus datos:</p>
<strong><?php echo $myError?></strong>
<p>Regrese a nuestro sitio y vuelva a ingresar sus datos por favor</p>

</body>
</html>
<?php
exit();
}
?>
Espero que te sirva, saludos!