-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathagregar.php
More file actions
67 lines (58 loc) · 2.39 KB
/
Copy pathagregar.php
File metadata and controls
67 lines (58 loc) · 2.39 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
62
63
64
65
66
67
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="assets/stylesform.css">
<title>Agregar Movimiento</title>
</head>
<body>
<section class="container">
<h1>Agregar Nuevo Movimiento</h1>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
<label for="fecha">Fecha:</label>
<input type="date" id="fecha" name="fecha" required><br>
<label for="tipo">Tipo:</label>
<select id="tipo" name="tipo" required>
<option value="ingreso">Ingreso</option>
<option value="egreso">Egreso</option>
</select><br>
<label for="descripcion">Descripción:</label>
<input type="text" id="descripcion" name="descripcion" required><br>
<label for="monto">Monto:</label>
<input type="number" step="0.01" id="monto" name="monto" required><br>
<label for="forma_de_pago">Forma de Pago:</label>
<select id="forma_de_pago" name="forma_de_pago" required>
<option value="efectivo">Efectivo</option>
<option value="cheque">Cheque</option>
<option value="tarjeta de crédito">Tarjeta de Crédito</option>
<option value="transferencia bancaria">Transferencia Bancaria</option>
</select><br>
<label for="id_familia">ID de Familia:</label>
<input type="number" id="id_familia" name="id_familia" required><br>
<input class="boton" type="submit" value="Agregar Movimiento">
</form>
</section>
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$fecha = $_POST["fecha"];
$tipo = $_POST["tipo"];
$descripcion = $_POST["descripcion"];
$monto = $_POST["monto"];
$forma_de_pago = $_POST["forma_de_pago"];
$id_familia = $_POST["id_familia"];
// Realiza la conexión a la base de datos y ejecuta la inserción
include 'conexion.php';
$conexion = conectar();
$sql = "INSERT INTO movimientos (fecha, tipo, descripcion, monto, forma_de_pago, id_familia)
VALUES ('$fecha', '$tipo', '$descripcion', $monto, '$forma_de_pago', $id_familia)";
if ($conexion->query($sql) === TRUE) {
echo "Nuevo movimiento agregado exitosamente.";
} else {
echo "Error al agregar el movimiento: " . $conexion->error;
}
cerrarConexion($conexion);
}
?>
</body>
</html>