<html>
<head>
<meta charset="utf-8">
<title>Biblioteca Escolar</title>
</head>

<body>

<form action="altaautor.php" method="get">
<table width="600" border="0" align="center">
<tbody>
<tr>
<td colspan="6" align="center"><strong>Alta de autores</strong></td>
</tr>
<tr>
<td colspan="3" align="right">Nombre:</td>
<td colspan="3"><input type="text" name="txtname"></td>
</tr>
<tr>
<td colspan="3" align="right">País:</td>
<td colspan="3"><input type="text" name="txtpais"></td>
</tr>
<tr>
<td width="34">&nbsp;</td>
<td width="67">&nbsp;</td>
<td width="179">&nbsp;</td>
<td width="144" align="center"><input type="submit" name="submit" id="submit" value="Guardar">
<input type="reset" name="reset" id="reset" value="Borrar"></td>
<td width="47">&nbsp;</td>
<td width="103">&nbsp;</td>
</tr>
</tbody>
</table>
</form>


</body>
</html>

<?php
$conexion = mysqli_connect("localhost", "root", "", "biblioteca");

if (!$conexion) {
    die("Error de conexión: " . mysqli_connect_error());
}

$nombre = $_GET['txtname'];
$pais   = $_GET['txtpais'];

$sql = "INSERT INTO autores (nombre, pais) VALUES ('$nombre', '$pais')";

if (mysqli_query($conexion, $sql)) {
    echo "Autor guardado correctamente: " . $nombre . " (" . $pais . ")";
} else {
    echo "Error: " . mysqli_error($conexion);
}

mysqli_close($conexion);
?>

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: