31 lines
879 B
PHP
Executable File
31 lines
879 B
PHP
Executable File
<?php
|
|
|
|
include("db.php");
|
|
|
|
// Verificar si se pasó el nombre de la tabla como parámetro
|
|
if (!isset($_GET['table'])) {
|
|
die("No se especificó una tabla.");
|
|
}
|
|
|
|
$table_name = $_GET['table'];
|
|
|
|
// Validar el nombre de la tabla
|
|
if (!preg_match('/^[a-zA-Z0-9_]+$/', $table_name)) {
|
|
die("El nombre de la tabla contiene caracteres no permitidos.");
|
|
}
|
|
|
|
if (isset($_POST['save_dataset'])) {
|
|
$instruction = $_POST['instruction'];
|
|
$input = $_POST['input'];
|
|
$output = $_POST['output'];
|
|
|
|
$query = "INSERT INTO $table_name (instruction, input, output) VALUES ('$instruction', '$input', '$output')";
|
|
$result = mysqli_query($conn, $query);
|
|
|
|
if (!$result) {
|
|
die("Error al insertar datos: " . mysqli_error($conn));
|
|
}
|
|
|
|
echo "<script>alert('Dataset guardado exitosamente.'); window.location.href = 'gestor_dataset.php?table=$table_name';</script>";
|
|
}
|