Calling the active user in a variable

Asked

Viewed 33 times

2

Guys, I’m trying to call the user logged in on this variable but it’s not working, I’d like to know where I’m going wrong.

<?php

include("../conexao_checkout.php");

$usuario     = $_SESSION['UsuarioID'];
$usuario_nome  = $_SESSION['UsuarioNome'];
$ip      = $_SERVER["REMOTE_ADDR"];
$data_contratado       = date('Y-m-d H:i:s');

$exibicao   = $_POST["exibicao"];
$filtro     = $_POST["filtro"];
$entrega    = $_POST["entrega"];
$contrata   = $_POST["contrata"];

if ($filtro > 0) {
    $cli = " AND `id_cliente` = ".$filtro;
}else{
    $cli = "";
}

if ($entrega  != "") {
    $data2 = str_replace('/', '-', $entrega);
    $nova_data2 = strftime("%Y-%m-%d", strtotime($data2));
    $ent = "AND `prazo_entrega` LIKE '%".$nova_data2."%' ";
}else{
    $ent = "";
}

if ($contrata  != "") {
    $data1 = str_replace('/', '-', $contrata);
    $nova_data = strftime("%Y-%m-%d", strtotime($data1));
    $cont = "AND `contratacao` LIKE '%".$nova_data."%' ";
}else{
    $cont = "";
}


$results = mysqli_query($conexao, "SELECT * FROM `servicos_filiais` WHERE `tecnico_interno` = $usuario {$cli} {$ent} {$cont};");

inserir a descrição da imagem aqui

1 answer

2


It is necessary to insert/declare session_start() at the beginning of the code, or before any call of the $_SESSION variables:

include("../conexao_checkout.php");

session_start();

$usuario = $_SESSION['UsuarioID']; $usuario_nome = $_SESSION['UsuarioNome']; $ip = $_SERVER["REMOTE_ADDR"]; $data_contratado = date('Y-m-d H:i:s');

...
  • 1

    worked out, damn it, thank you.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.