Good morning.
I have the following snippet:
if (isset($_POST["acao"]) && $_POST["acao"]=="pgto") {
if(empty($_SESSION["carrinho"])) {print 20;}
if(!isset($_SESSION["carrinho"])) {print 40;}
print "<pre>";
print_r($_SESSION["carrinho"]);
print "</pre>";
if(empty($_SESSION["carrinho"]) || (!isset($_SESSION["carrinho"]))) {
echo "<h1 class='erro'>Carrinho Vazio!</h1>";
print "<pre>";
print_r($_SESSION["carrinho"]);
print "</pre>";
} else {
print "<pre>";
print_r($_SESSION["carrinho"]);
print "</pre>";
require_once "pedidoGravar.php";
require_once "pedidoGravado.php";
if (isset($_POST["pagamento"]) && $_POST["pagamento"]=="boleto") {
require_once "boleto.php";
}
if (isset($_POST["pagamento"]) && $_POST["pagamento"]=="pagseguro") {
require_once "pagSeguro.php";
}
if (isset($_POST["pagamento"]) && ($_POST["pagamento"]=="mastercard" || $_POST["pagamento"]=="visa")) {
require_once "cartao.php";
}
}
}
What happens is the following >
The session is usually printed on all
print_r($_SESSION["carrinho"]);
The code is normally entering both
if(empty($_SESSION["carrinho"]) || (!isset($_SESSION["carrinho"]))) { ...
How much in your else
} else {
print "<pre>";
print_r($_SESSION["carrinho"]);
print "</pre>";
require_once "pedidoGravar.php";
require_once "pedidoGravado.php";
}
What could be happening?
On page pedidoGravar.php
I use the session to write to the bank and I unset the session of the cart.
In pedidoGravado.php
, I display what was written to the bank normally.
But, it is normally passing both% w / o% and% w /%.