forked from pacohunterdev/ventas-php
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathagregar_cliente.php
More file actions
61 lines (55 loc) · 1.9 KB
/
agregar_cliente.php
File metadata and controls
61 lines (55 loc) · 1.9 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
include_once "encabezado.php";
include_once "navbar.php";
session_start();
if(empty($_SESSION['usuario'])) header("location: login.php");
?>
<div class="container">
<h3>Agregar cliente</h3>
<form method="post">
<div class="mb-3">
<label for="nombre" class="form-label">Nombre</label>
<input type="text" name="nombre" class="form-control" id="nombre" placeholder="Escribe el nombre del cliente">
</div>
<div class="mb-3">
<label for="telefono" class="form-label">Teléfono</label>
<input type="text" name="telefono" class="form-control" id="telefono" placeholder="Ej. 2111568974">
</div>
<div class="mb-3">
<label for="direccion" class="form-label">Dirección</label>
<input type="text" name="direccion" class="form-control" id="direccion" placeholder="Ej. Av Collar 1005 Col Las Cruces">
</div>
<div class="text-center mt-3">
<input type="submit" name="registrar" value="Registrar" class="btn btn-primary btn-lg">
</input>
<a href="clientes.php" class="btn btn-danger btn-lg">
<i class="fa fa-times"></i>
Cancelar
</a>
</div>
</form>
</div>
<?php
if(isset($_POST['registrar'])){
$nombre = $_POST['nombre'];
$telefono = $_POST['telefono'];
$direccion = $_POST['direccion'];
if(empty($nombre)
|| empty($telefono)
|| empty($direccion)){
echo'
<div class="alert alert-danger mt-3" role="alert">
Debes completar todos los datos.
</div>';
return;
}
include_once "funciones.php";
$resultado = registrarCliente($nombre, $telefono, $direccion);
if($resultado){
echo'
<div class="alert alert-success mt-3" role="alert">
Cliente registrado con éxito.
</div>';
}
}
?>