6
Hello. I have the following folder hierarchy:
Folder "mother" with the following: Submit.php file, with the following code:
<?php
ini_set('display_errors',1);
ini_set('display_startup_erros',1);
error_reporting(E_ALL);
include("libs/submit.php");
Folder /templates, which has the file submit.php
, with the following code:
<html>
<head>
<meta charset='UTF-8'>
</head>
<body>
<input type="file" name='foto' id="file-upload" style="display:none;">
<input type="submit" class="upload_button" value="Submit">
<div class='editable'>Oi pra mim e pra vc</div>
<script>
$(document).ready(function() {
$(".upload_button").click(function() {
var descricaoArteHTML = $(".editable").Editor("getText");
$.ajax({
url: '/',
data: {descricaoArte : descricaoArteHTML},
type: 'POST',
success: function(output) {
alert(output);
},
error: function(request, status, error){
alert("Error: Could not delete");
}
});
});
});
</script>
</body>
And the libs/ folder, which has the file submit.php
with the following code:
<?php
ini_set('display_errors',1);
ini_set('display_startup_erros',1);
error_reporting(E_ALL);
session_start();
if(isset($_SESSION['usuario_logado'])){
include "config.php";
include "banco.php";
include "helper.php";
$tem_erros = false;
if (tem_post()) {
if (! isset($_FILES['foto'])) {
$tem_erros = false;
} else {
if (tratar_foto($_FILES['foto'])) {
$foto = array();
$foto['arquivo'] = $_SESSION['rand'];
$foto['descricao'] = $_POST['descricaoArte'];
} else {
$tem_erros = true;
}
}
if (! $tem_erros) {
gravar_foto($mysqli, $foto);
}
}
include "./templates/submit.php";
What happens is the photo is recorded in the database, but the description does not, and I get the following error:
Notice: Undefined index: Descricao in /home/u175477054/public_html/libs/Submit.php on line 44
In the Ajax part, in the URL part, I have tried several ways, but always get the same error.
How to record the description in the bank?