-
Notifications
You must be signed in to change notification settings - Fork 3
/
insertBD.php
46 lines (37 loc) · 947 Bytes
/
insertBD.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
<?php
/**
* @file insertBD.php
* @version 1.0
* @author Linea de Codigo (http://lineadecodigo.com)
* @date 5-febrero-2013
* @url http://lineadecodigo.com/php/insertar-elementos-en-mysql-con-php/
* @description Programa que inserta un elemento en una base de datos MySQL
*/
?>
<!doctype html>
<html>
<head><title>Insertando Elemento...</title></head>
<body>
<h1>Insertando Elemento...</h1>
<?php
// Recuperamos el nombre del formulario
$nombre = $_POST['nombre'];
if (!$nombre) {
echo "Tienes que insertar un valor para el autor";
exit;
}
@ $db = new mysqli(localhost, "root", "", "biblioteca");
if (mysqli_connect_errno()){
echo "Error conectando con la base de datos";
exit;
} else {
$result = $db->query($query);
if ($result)
echo $db->affected_rows." fila(s) afectada(s). Información insertada correctamente";
else
echo "Ha ocurrido un problema insertando los datos";
$db->close();
}
?>
</body>
</html>