I have a textarea to which I write a query like: SELECT* FROM usuarios
to process them in a php document and be able to extract the result of this query.
Everything goes well in this aspect, but whenever I use clauses, such as: LIMIT or WHERE, it sends me an error 403 (Forbidden) indicating the path of my .php file where I process the query.
Why is this happening? I was reading about it with similar problems but none helped me. I have my hosting in Godaddy and the information process with JQuery and Ajax. I will value any help in this regard. Thanks.
HTML
<form>
<label>Consulta</label>
<textarea class="form-control" rows="3" placeholder="Consulta SQL"></textarea>
</form>
<hr>
<button type="button" id="ejecutar-consulta" class="btn btn-default"><span class="glyphicon glyphicon-cog"></span> Ejecutar</button>
JQuery
var dataContent;
(function() {
$('textarea').focus();
$('body').on('click','#ejecutar-consulta', function() {
$('#ejecutar-consulta').hide();
$('textarea').removeAttr('style');
$('.response-sql').html('<i style="font-size:17px;" class="fa fa-spinner fa-spin fa-3x fa-fw"></i> Ejecutando consulta...');
var consulta = $('textarea').val().trim();
if ( consulta.length > 0 ) {
$.post('includes/herramientas/generador-reportes/controller.php',{key:'ejecutar-consulta',sql:consulta}, function(dataResponse) {
dataContent = dataResponse;
}).complete(function() {
console.log(dataContent);
})
}
else {
console.log('Error al procesar la solicitud.');
}
});
})();
PHP
$sql = $_POST['sql'];
$DoQuery = $db->sql($sql);
$GetColumns = mysqli_fetch_assoc($DoQuery);
$headersTable = array_keys($GetColumns);
while ( $f_informacion = mysqli_fetch_assoc($DoQuery) ) :
$contentOne = array();
for ( $i = 0; $i < count($headersTable); $i++ ) :
$contentOne[] = utf8_encode($f_informacion[$headersTable[$i]]);
endfor;
$contenidoSQL[] = $contentOne;
endwhile;