-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate.php
88 lines (82 loc) · 3.73 KB
/
create.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>CRUD con PHP usando Programación Orientada a Objetos</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto|Varela+Round|Open+Sans">
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="css/custom.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<div class="table-wrapper">
<div class="table-title">
<div class="row">
<div class="col-sm-8"><h2>Agregar <b>Cliente</b></h2></div>
<div class="col-sm-4">
<a href="index.php" class="btn btn-info add-new"><i class="fa fa-arrow-left"></i> Regresar</a>
</div>
</div>
</div>
<?php
include ("database.php");
$clientes= new Database();
if(isset($_POST) && !empty($_POST)){
$nombres = $clientes->sanitize($_POST['nombres']);
$apellidos = $clientes->sanitize($_POST['apellidos']);
$telefono = $clientes->sanitize($_POST['telefono']);
$direccion = $clientes->sanitize($_POST['direccion']);
$correo_electronico = $clientes->sanitize($_POST['correo_electronico']);
$res = $clientes->create($nombres, $apellidos, $telefono, $direccion, $correo_electronico);
if($res){
$message= "Datos insertados con éxito";
$class="alert alert-success";
}else{
$message="No se pudieron insertar los datos";
$class="alert alert-danger";
}
?>
<div class="<?php echo $class?>">
<?php echo $message;?>
</div>
<?php
}
?>
<div class="row">
<form method="post">
<div class="col-md-6">
<label>Nombres:</label>
<input type="text" name="nombres" id="nombres" class='form-control' maxlength="100" required >
</div>
<div class="col-md-6">
<label>Apellidos:</label>
<input type="text" name="apellidos" id="apellidos" class='form-control' maxlength="100" required>
</div>
<div class="col-md-12">
<label>Dirección:</label>
<textarea name="direccion" id="direccion" class='form-control' maxlength="255" required></textarea>
</div>
<div class="col-md-6">
<label>Teléfono:</label>
<input type="text" name="telefono" id="telefono" class='form-control' maxlength="15" required >
</div>
<div class="col-md-6">
<label>Correo electrónico:</label>
<input type="email" name="correo_electronico" id="correo_electronico" class='form-control' maxlength="64" required>
</div>
<div class="col-md-12 pull-right">
<hr>
<button type="submit" class="btn btn-success">Guardar datos</button>
</div>
</form>
</div>
</div>
</div>
</body>
</html>