-
Notifications
You must be signed in to change notification settings - Fork 0
/
destino.php
64 lines (51 loc) · 1.85 KB
/
destino.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
<?php
include "conexion.php";
$id=$_POST[id];
$situacion=$_POST[valor1];
if ($situacion=='1'){
$nombre=$_POST[nombre];
$apellido=$_POST[apellido];
if($con){
$sql = "select * from usuarios where documento like '$id'";
$resultado = $con->query($sql) or die($con->error);
if ($resultado){
if(mysqli_num_rows($resultado) > 0) {
//encontro el registro no se puede agregar
echo '<br><div class="alert alert-danger" role="alert">
<button type="button" class="close" data-dismiss="alert">×</button>
<strong>El Documento Ingresado ya existe, por favor verifique el mismo e intente nuevamente</strong>
</div>';
exit();
}else{
//agrego el registro
$sql = "insert into usuarios (documento, nombre, apellido) values ('$id', '$nombre', '$apellido')";
$query = $con->query($sql);
echo '<br><div class="alert alert-success" role="alert">
<button type="button" class="close" data-dismiss="alert">×</button>
<strong>El usuario se ha dado de alta correctamente</strong><br>
</div>';
exit();
}
}else{
echo '<br><div class="alert alert-danger" role="alert">
<button type="button" class="close" data-dismiss="alert">×</button>
<strong>Ha ocurrido un error accediento a la base de datos!!!</strong>
</div>';
exit();
}
}
}
if ($situacion=='2'){
if($con){
$sql = "delete from usuarios where documento like '$id'";
$resultado = $con->query($sql) or die($con->error);
if ($resultado){
echo '<br><div class="alert alert-danger" role="alert">
<button type="button" class="close" data-dismiss="alert">×</button>
<strong>El usuario ha sido dado de baja correctamente</strong>
</div>';
exit();
}
}
}
?>