I have a CRUD but when I insert it, I get the following error:
"Forbidden access! You do not have permission to access the requested object. The object is protected against reading or the server can not read it. If you believe that this is a server error, please communicate it to the portal administrator. Error 403 localhost Apache / 2.4.17 (Win32) OpenSSL / 1.0.2d PHP / 5.6.15 "
What I want is that each insertion takes me to the same page but with the record inserted the code is as follows:
<?php
$sql_local = "SELECT * FROM DATOS_USUARIOS";
$resultado = $base->prepare($sql_local);
$resultado->execute(array());
//--------- insertar datos----------
#si has pulsado el boton insertar
if(isset($_POST["agregar"])) {
//almaceno las variables del formulario
$nombre = $_POST["Nom"];
$apellido = $_POST["Ape"];
$direccion = $_POST["Dir"];
$sql = "INSERT INTO DATOS_USUARIOS (NOMBRE, APELLIDO, DIRECCION) VALUES(:nom, :ape, :dir)";
$resultado = $base->prepare($sql);
$resultado->execute(array(
":nom" => $nombre,
":ape" => $apellido,
":dir" => $direccion
));
header("Location:index.php");
}
?>
<h1>CRUD<span class="subtitulo">Create Read Update Delete</span></h1>
<form action="<?php echo $_SERVER['$PHP_SELF']; ?>" method="post">
<table width="50%" border="0" align="center">
<tr>
<td class="primera_fila">Id</td>
<td class="primera_fila">Nombre</td>
<td class="primera_fila">Apellido</td>
<td class="primera_fila">Dirección</td>
<td class="sin"> </td>
</tr>
<?php
#por aca objeto persona que hay en el array registros repiteme el codigo que esta en el foreach
foreach($registros as $persona): ?>
<tr>
<td><?php echo $persona->Id ?> </td>
<td><?php echo $persona->Nombre ?></td>
<td><?php echo $persona->Apellido ?></td>
<td><?php echo $persona->Direccion ?></td>
<?php endforeach; //cierro boloque foreach ?>
<tr>
<td></td>
<td><input type='text' name='Nom' size='10' class='centrado'></td>
<td><input type='text' name='Ape' size='10' class='centrado'></td>
<td><input type='text' name=' Dir' size='10' class='centrado'></td>
<td class='bot'><input type='submit' name='agregar' id='agregar' value='Insertar'></td>
</tr>
<!-- /.. -->
I am working with phpMyAdmin with MySQL.