La forma de contacto manda a una pagina en blanco
Publicado por Maria EugeniaCabañas (2 intervenciones) el 09/09/2016 02:52:49
ya validé el código PHP y no tiene errores al igual que el html5. no se porque no funciona,gracias por su ayuda.
php
html
php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<?php
if(isset($_POST['email'])) {
// Edita las dos líneas siguientes con tu dirección de correo y asunto personalizados
$Email_to = "info@hotelreal.com";
$Email_subject = "Nuevo Mensaje de un Cliente";
function died($error) {
// si hay algún error, el formulario puede desplegar su mensaje de aviso
echo "Lo sentimos, hubo un error en sus datos y el formulario no puede ser enviado en este momento. ";
echo "Detalle de los errores.<br /><br />";
echo $error."<br /><br />";
echo "Porfavor corrija estos errores e inténtelo de nuevo.<br /><br />";
die();
}
// Se valida que los campos del formulairo estén llenos
if(!isset($_POST['Nombre']) ||
!isset($_POST['Apellido']) ||
!isset($_POST['Pais']) ||
!isset($_POST['Email']) ||
!isset($_POST['Telefono']) ||
!isset($_POST['Llegada']) ||
!isset($_POST['Salida']) ||
!isset($_POST['Habitaciones']) ||
!isset($_POST['mensaje'])) {
died('Lo sentimos pero parece haber un problema con los datos enviados.');
}
//En esta parte el valor "name" nos sirve para crear las variables que recolectaran la información de cada campo
$Nombre = $_POST['Nombre']; // requerido
$Apellido = $_POST['Apellido']; // requerido
$Pais = $_POST['Pais']; // requerido
$Email_from = $_POST['Email']; // requerido
$Telefono = $_POST['Telefono']; // no requerido
$Llegada = $_POST['Llegada']; // requerido
$Salida = $_POST['Salida']; // requerido
$Habitaciones = $_POST['Habitaciones']; // requerido
$mensaje = $_POST['mensaje']; // requerido
$error_message = "Error";
//En esta parte se validan las cadenas de texto
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$Nombre)) {
$error_message .= 'El formato del nombre no es válido<br />';
}
if(!preg_match($string_exp,$Apellido)) {
$error_message .= 'el formato del apellido no es válido.<br />';
}
if(strlen($mensaje) < 2) {
$error_message .= 'El formato del texto no es válido.<br />';
}
if(strlen($error_message) < 0) {
died($error_message);
}
//A partir de aqui se contruye el cuerpo del mensaje tal y como llegará al correo
$Email_mensaje = "Contenido del Mensaje.\n\n";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$Email_mensaje .= "Nombre: ".clean_string($Nombre)."\n";
$Email_mensaje .= "Apellido: ".clean_string($Apellido)."\n";
$Email_mensaje .= "Pais: ".clean_string($Pais)."\n";
$Email_mensaje .= "Email: ".clean_string($Email_from)."\n";
$Email_mensaje .= "Teléfono: ".clean_string($Telefono)."\n";
$Email_mensaje .= "Llegada: ".clean_string($Fecha)."\n";
$Email_mensaje .= "Salida: ".clean_string($Fecha)."\n";
$Email_mensaje .= "Habitaciones: ".clean_string($Habitaciones)."\n";
$email_mensaje .= "Mensaje: ".clean_string($mensaje)."\n";
//Se crean los encabezados del correo
$headers = 'From: '.$Email_from."\r\n".
'Reply-To: '.$Email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($Email_to, $Email_subject, $Email_mensaje, $headers);
echo "Gracias,pronto estaremos en contacto" ;
?>
<?php
}
?>
html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<div class="col-md-8 contact-right" id="contact">
<div class="contact-details">
<h3><b>DATOS CONTACTO</b></h3>
<div class="text-field-name-1">
<form name="contactform" method="post" action="send_form_email.php">
<input type="text" class="text" value=" Nombre*" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = ' Nombre*';}">
<input type="text" class="text" value="Apellido*" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Apellido*';}">
<input type="text" class="text" value=" País" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = ' Pais';}">
<input type="text" class="text" value="Email*" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Email*';}">
<input type="text" class="text" value=" Teléfono" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = ' Telefono';}">
</form>
</div>
</div>
<div class="reservation-details">
<h3><b>RESERVA AHORA</b></h3>
<div class="text-field-name-1">
<form name="contactform" method="post" action="send_form_email.php">
<input type="text" class="text" value="Llegada*" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = ' Llegada*';}">
<input type="text" class="text" value="Salida*" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Salida';}">
<input type="text" class="text" value=" Habitaciónes*" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = ' Habitaciones*';}">
</form>
</div>
<div class="text-field-name-2">
<form name="contactform" method="post" action="send_form_email.php">
<textarea name=mensaje rows="4">Mensaje*</textarea>
</form>
</div>
</div>
<div class="clearfix"> </div>
<div class="button">
<form name="contactform" method="post" action="send_form_email.php">
<input type="submit" value="Enviar"> <a href="http://www.hotelreal.com/send_form_email.php"></a>
</form>
</div>
</div>
Valora esta pregunta


0