-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrecibe_excel_validando.php
More file actions
39 lines (34 loc) · 1.44 KB
/
recibe_excel_validando.php
File metadata and controls
39 lines (34 loc) · 1.44 KB
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
<?php
require('config.php');
$tipo = $_FILES['dataCliente']['type'];
$tamanio = $_FILES['dataCliente']['size'];
$archivotmp = $_FILES['dataCliente']['tmp_name'];
$lineas = file($archivotmp);
$i = 0;
foreach ($lineas as $linea) {
$cantidad_registros = count($lineas);
$cantidad_regist_agregados = ($cantidad_registros - 1);
if ($i != 0) {
$datos = explode(";", $linea);
$nombre = !empty($datos[0]) ? ($datos[0]) : '';
$correo = !empty($datos[1]) ? ($datos[1]) : '';
$celular = !empty($datos[2]) ? ($datos[2]) : '';
if (!empty($celular)) {
$checkemail_duplicidad = ("SELECT celular FROM clientes WHERE celular='" . ($celular) . "' ");
$ca_dupli = mysqli_query($con, $checkemail_duplicidad);
$cant_duplicidad = mysqli_num_rows($ca_dupli);
}
//No existe Registros Duplicados
if ($cant_duplicidad == 0) {
$insertarData = "INSERT INTO clientes(nombre, correo, celular)VALUES('$nombre', '$correo', '$celular')";
mysqli_query($con, $insertarData);
} else {
/**Caso Contrario actualizo el o los Registros ya existentes*/
$updateData = ("UPDATE clientes SET nombre='" . $nombre . "', correo='" . $correo . "', celular='" . $celular . "' WHERE celular='" . $celular . "'");
$result_update = mysqli_query($con, $updateData);
}
}
$i++;
}
?>
<a href="index.php">Atras</a>