Ayuda para insertar datos a mysql y enviar por correo
Publicado por JOSE ALFREDO (2 intervenciones) el 28/03/2020 22:50:16
Hola, tengo un problema quisiera su ayuda, tengo el siguiente codigo actualmente trabajo con xampp desde el localhost al momento de terminar toda la reserva y revisar mi base de datos no se me inserta nungun solo dato y tampoco se envia a los correos proporcionados, gracias.

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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
<?php
require_once("complete/config.php");
$fecha_actual=date("Y-m-d");
$tipo_servicio = "Redondo";//$_POST['tipo_servicio'];
$servicio = $_POST['servicio'];
$desde = $_POST['desde'];
$hotel = $_POST['hotel'];
$localizado= $_POST['localizado'];
$personas = $_POST['personas'];
$precio = $_POST['precio'];
$unidad = $_POST['unidad'];
$llegada = $_POST['llegada'];
$salida = $_POST['salida'];
$precio = $_POST['precio'];
$nombre = $_POST['nombre'];
$apellido = $_POST['apellido'];
$mail = $_POST['mail'];
$telefono = $_POST['telefono'];
$estado = $_POST['estado'];
$aerolinea1 = $_POST['aerolinea1'];
$vuelo1 = $_POST['vuelo1'];
$hora_llegada = $_POST['hora_llegada'];
$minuto_llegada = $_POST['minuto_llegada'];
$aerolinea2 = $_POST['aerolinea2'];
$vuelo2 = $_POST['vuelo2'];
$hora_salida = $_POST['hora_salida'];
$minuto_salida = $_POST['minuto_salida'];
$forma_pago = $_POST['forma_pago'];
$comentarios = $_POST['comentarios'];
$lo_terminal = "Select * from aerolineas Where aerolinea = '$aerolinea1'";
$qryTerminal = mysqli_query($conn, $lo_terminal);
while($terminal = mysqli_fetch_array($qryTerminal)) {
$acronimo = $terminal['acronimo'];
$T = $terminal['terminal'];
}
/* Ultimo Numero de Reserva */
$con_ultimaReserva = "Select Max(idReserva) AS ult_reserva from reservaciones";
$qryReserva_ul = mysqli_query($conn, $con_ultimaReserva);
while($sig_reserva = mysqli_fetch_array($qryReserva_ul)) {
$lo_reservacion2 = $sig_reserva['ult_reserva'];
}
$b = '1';
$lo_reserva = $lo_reservacion2 + $b;
$body = "
?>
<!doctype html>
<html>
<head>
<meta charset='utf-8'>
<title>Documento sin título</title>
</head>
<body>
<table width='40%' border='0' cellpadding='0' cellspacing='0'>
<tbody>
<tr>
<td colspan='2'><img src='images/banner.fw.png' width='765' height='117' /></td>
</tr>
<tr>
<td width='50%'>Reservation Booking / Numero de Reserva</td>
<td width='50%'>Book - $lo_reserva / $unidad</td>
</tr>
<tr>
<td>Service Required / Servicio Reservado</td>
<td>$servicio - Rate - Costo <strong>$precio USD</strong></td>
</tr>
<tr>
<td>Hotel Name / Nombre Hotel</td>
<td>$hotel</td>
</tr>
<tr>
<td>Located in / Localizado en</td>
<td>$localizado</td>
</tr>
<tr>
<td>Customer Name / Nombre de Cliente</td>
<td>$nombre
$apellido</td>
</tr>
<tr>
<td>#People in the Party / #Personas </td>
<td>$personas People / Personas</td>
</tr>
<tr>
<td>EMail Address / Direccion Email</td>
<td>$mail</td>
</tr>
<tr>
<td>Mobile Phone / Telefono Celular</td>
<td>$telefono</td>
</tr>
<tr>
<td>Arrival Day / Fecha Llegada</td>
<td>$llegada</td>
</tr>
<tr>
<td height='21'>Airline & Flight Number / Aerolinea y # Vuelo</td>
<td>$aerolinea1 $acronimo / # $vuelo1 Llegada x Terminal $T</td>
</tr>
<tr>
<td>Arrival Time / Hora Llegada</td>
<td>$hora_llegada:$minuto_llegada Hrs</td>
</tr>
<tr>
<td>Departure Day / Fecha de Salida</td>
<td>$salida</td>
</tr>
<tr>
<td>Airline & Flight Number / Aerolinea y # Vuelo</td>
<td>$aerolinea2 / Fight # $vuelo2</td>
</tr>
<tr>
<td>Departure Time / Hora Salida</td>
<td>$hora_salida:$minuto_salida Hrs</td>
</tr>
<tr>
<td>Mehod Pay / Forma de pago</td>
<td>$forma_pago</td>
</tr>
<tr>
<td>Comments / Comentarios</td>
<td> </td>
</tr>
<tr>
<td colspan='2'>$comentarios</td>
</tr>
<tr>
<td colspan='2' align='center' bgcolor='#F6FC17'><div>
<p><span style='font-size: 24px'><a href='www.transferusamerica.com' target='_blank'>http://transferusamerica.com</a><br>
Reservations & Customer Services</span><br>
Phone 1/Telefono 1 : +52 998 2110778 - Telefono 2/ Phone 2 : +52 998 2736390<br>
E-Mail : <a href='mailto:bestlinecun@gmail.com'>info@bestlinecancun.com</a></p>
</div></td>
</tr>
<tr>
<td colspan='2' align='center'> </td>
</tr>
</tbody>
</table>
</body>
</html>
";
/*INICIANDO*/
$servername = 'localhost';
$username = 'root';
$password = '';
$dbname = 'tr4nsf3r';
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$lo_status = "http://oscarcancunshuttle.com/sistema/imagen/alerta.jpg";
$sql = "INSERT INTO reservaciones (fecha_captura, idReserva, servicio, tipo_servicio, fllegada, pax, hotel, localizado, cliente, email, telefono, celulaar, pais, ciudad, aerolineallegada, vuelollegada, horallegada, aerolineasalida, vuelosalida, comentarios, Activo, fsalida, costo, tipo_unidad, hora_departure, forma_pago)
VALUES
('$fecha_actual', '$lo_reserva', '$servicio', '$tipo_servicio', '$llegada', '$personas', '$hotel', '$localizado', '$nombre', '$mail', '$telefono', '$telefono', '$estado','Cancun', '$aerolinea1', '$vuelo1', '$hora_llegada:$minuto_llegada',
'$aerolinea2', '$vuelo2','$comentarios', '1', '$salida', '$precio', '$unidad', '$hora_salida:$minuto_salida', '$forma_pago')";
if ($conn->query($sql) === TRUE) {
echo'<script type="text/javascript">
alert("New record created successfully");
window.location.href="index.php";
</script>';
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
$headers = "From: Reservation Transfer Usamerica <transferusamerica@gmail.com>\n" .
'X-Mailer: PHP/' . phpversion() . "\n" .
"MIME-Version: 1.0\n" .
"Content-Type: text/html; charset=utf-8\n" .
"Content-Transfer-Encoding: 8bit\n";
mail("transferusamerica@gmail.com","Reservation Transfer Usamerica",$body,$headers);
mail("info@transferusamerica.com","Reservation Transfer Usamerica",$body,$headers);
mail($email,"Reservation Transfer Usamerica",$body,$headers);
header("Location: ../index.php");
?>

Valora esta pregunta


0