-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinsertar_db.php
More file actions
48 lines (31 loc) · 1023 Bytes
/
insertar_db.php
File metadata and controls
48 lines (31 loc) · 1023 Bytes
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
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Insertar Bases de Datos</title>
</head>
<body>
<?php
$seccion=$_GET["txtSeccion"];
$nombre=$_GET["txtNombre"];
$fecha=$_GET["txtFecha"];
$pais=$_GET["txtPais"];
$precio=$_GET["numPrecio"];
//Se utilizan los datos del archivo conexion_db.php
require ("conexion_db.php");
//Se genera la conexion a la DB.
$conexion=mysqli_connect($db_host,$db_user,$db_pass,$db_name);
//Validar conexion a la DB
if(mysqli_connect_errno()){
echo "Falla al conectar la base de datos" . mysqli_connect_error() . PHP_EOL;
exit();
}
// Para que cononozca acentos.
mysqli_set_charset($conexion,"utf-8");
$query = "INSERT INTO ARTICULOS (SECCION, NOMBRE_ARTICULO, FECHA, PAIS_DE_ORIGEN, PRECIO)
VALUES ('$seccion', '$nombre', '$fecha', '$pais', $precio)";
$resultado = mysqli_query($conexion, $query);
echo $resultado;
?>
</body>
</html>