Ver Mensaje Individual
  #1 (permalink)  
Antiguo 10/09/2010, 12:57
Avatar de rodrypaladin
rodrypaladin
Moderador
 
Fecha de Ingreso: abril-2010
Ubicación: Madrid
Mensajes: 2.127
Antigüedad: 14 años, 1 mes
Puntos: 468
Mensaje Redireccionar cuando se envia correo mediante formulario

Buenas tardes, tengo un formulario que funciona correctamente pero cuando se envia el Correo sale una pagina en blanco que pone texto y lo que me gustaría es que si se envia bien redireccione a una pagina "contactoOK.html" por ejemplo y si se envia mal redireccione a otrs "contactoERROR.html" sabriais como hacerlo??

busque en google como redireccionar en php, y me saló esto

Cita:
<?php
Header("Location: tupagina.php");
?>
eso lo sustituyo por la linea de codigo cuandos e envia correctamente pero no funciona..¿Sabeis como solucionarlo ?

os pego el codigo demi formulario por si os ayuda

Cita:
<?php

/**
* Contact form PHP
* Credits: http://dev-tips.com/featured/ajax-and-php-contact-form
*/

// If the form have been submitted and the spam check field is empty
if ( isset( $_POST['name'] ) && empty( $_POST['spam_check'] ) ) {

// Enter your email
$mail = '[email protected]';

// Include our email validator for later use
require 'inc/email-validator.php';
$validator = new EmailAddressValidator();

// Declare our $errors variable we will be using later to store any errors.
$errors = array();

$name = strip_tags( $_POST['name'] );
$emailfrom = strip_tags( $_POST['email'] );
$subject = strip_tags( $_POST['subject'] );
$message = strip_tags( utf8_decode( $_POST['message'] ) ); // Use uft8_decode to make special characters æ, ø, å, ü and é work

// Set a default subject
if ( empty( $subject ) )
$subject = 'Default subject';

// We'll check and see if any of the required fields are empty.
// We use an array to store the required fields.
$required = array( 'Name' => 'name', 'Email' => 'email', 'Message' => 'message' );

// Loops through each required $_POST value
// Checks to ensure it is not empty.
foreach ( $required as $key => $value ) {
if( isset( $_POST[$value] ) && $_POST[$value] !== '' )
continue;
else
$errors[] = $key . ' cannot be left blank';
}

// Make sure the email is valid.
if ( !$validator->check_email_address( $emailfrom ) )
$errors[] = 'Email address is invalid';

// Now check to see if there are any errors
if ( empty( $errors ) ) {

// No errors, send mail using conditional to ensure it was sent.
if( mail( $mail, "$subject", $message, "From: $emailfrom" ) )
echo '<p class="success">Tu Email se ha enviado Correctamente</p>';
else
echo '<p class="error">ERROR!! No se ha podido enviar el correo</p>';

} else {

// Errors were found, output all errors to the user.
echo '<p class="error">';
echo implode( '<br />', $errors );
echo '</p>';

}

} else { // The user have tried to access thid page directly or this a spambot
echo "You're not allowed to access this page directly";
}

?>
__________________
No te olvides de dar +1 a quien te echa un cable ;)