1
I’m limiting the amount of posts a user posts on a service so I created the function:
function limite($conexao, $id) {
$query = "select cont_post from usuarios where id={$id}";
return mysqli_fetch_assoc($query);
}
and in the logic of registration I made the condition:
$numLimite = limite($conexao, $id);
if($numLimite['cont_post'] >= 5) {
header("Location: profile.php?=Limite");
}else{
$id_empresa = $_POST['id_empresa'];
$localizacao = $_POST['localizacao'];
$img = $_FILES['img'];
$titulo = $_POST['titulo'];
$texto = $_POST['texto'];
$telefone = $_POST['telefone'];
$email = $_POST['email'];
$site = $_POST['site'];
if(isset($_FILES['img'])) {
$nomes = $img['name'];
$tiposPermitidos = ['jpg', 'jpeg', 'png'];
$tamanho = $marca['size'];
$extensao = explode('.', $nomes);
$extensao = end($extensao);
$novoNome = rand().'.'.$extensao;
if(in_array($extensao, $tiposPermitidos)) {
if($tamanho > 2000000) {
echo "tamanho exede o limite perfimitido";
} else {
$mover = move_uploaded_file($_FILES['img']['tmp_name'], 'envios/'.$novoNome);
//echo "<img src='envios/$novoNome'>";
}
} else {
echo "tipo de arquivo inválido";
}
}
cadastraFolder($conexao, $id_empresa, $localizacao, $novoNome, $titulo, $texto, $telefone, $email, $site);
cont_post($conexao, $id, null);
header("Location: profile.php");
}
But it’s not working, can anyone help me? Thank you
Some mistake, which doesn’t work?
– MagicHat