66 lines
2.3 KiB
PHP
Executable File
66 lines
2.3 KiB
PHP
Executable File
<?php
|
|
|
|
include("db.php");
|
|
|
|
// Verificar si se pasaron los parámetros 'id' y 'table'
|
|
if (!isset($_GET['id']) || !isset($_GET['table'])) {
|
|
die("No se especificaron los parámetros necesarios.");
|
|
}
|
|
|
|
$id = $_GET['id'];
|
|
$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.");
|
|
}
|
|
|
|
// Obtener el registro de la base de datos
|
|
$query = "SELECT * FROM $table_name WHERE id = $id";
|
|
$result = mysqli_query($conn, $query);
|
|
if (mysqli_num_rows($result) == 1) {
|
|
$row = mysqli_fetch_array($result);
|
|
$instruction = $row['instruction'];
|
|
$input = $row['input'];
|
|
$output = $row['output'];
|
|
}
|
|
|
|
// Actualizar el registro en la base de datos
|
|
if (isset($_POST['update_dataset'])) {
|
|
$instruction = $_POST['instruction'];
|
|
$input = $_POST['input'];
|
|
$output = $_POST['output'];
|
|
|
|
$query = "UPDATE $table_name SET instruction = '$instruction', input = '$input', output = '$output' WHERE id = $id";
|
|
mysqli_query($conn, $query);
|
|
header("Location: gestor_dataset.php?table=$table_name");
|
|
}
|
|
|
|
?>
|
|
|
|
<?php include("includes/header.php"); ?>
|
|
|
|
<div class="container p-4">
|
|
<div class="row">
|
|
<div class="col-md-4 mx-auto">
|
|
<div class="card card-body">
|
|
<form action="edit.php?table=<?php echo $table_name; ?>&id=<?php echo $id; ?>" method="POST">
|
|
<div class="form-group mb-3">
|
|
<input type="text" name="instruction" class="form-control" value="<?php echo $instruction; ?>" placeholder="Update Instruction" autofocus>
|
|
</div>
|
|
<div class="form-group mb-3">
|
|
<input type="text" name="input" class="form-control" value="<?php echo $input; ?>" placeholder="Update Input">
|
|
</div>
|
|
<div class="form-group mb-3">
|
|
<textarea name="output" rows="2" class="form-control" placeholder="Update Output"><?php echo $output; ?></textarea>
|
|
</div>
|
|
<button class="btn btn-success" name="update_dataset">
|
|
Update Dataset
|
|
</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<?php include("includes/footer.php"); ?>
|