Сеанс в PHP закрывается, сделав какое-то движение внутри страницы

Моя проблема коренится, в котором я наставляю сеанс, я делаю движение внутри, например, печатаю статью, но когда я хочу издать это, он достает меня главную страницу.

Я не знаю, чем была ошибка, у меня есть понятия, которых это сеанс, но правда я не уверен. Я исследовал относительно сеансов с PHP, но правда я не знаю, что делать.

Восток - тот модальный, чтобы инициализировать сеанс:

<div class="modal fade" id="modal-3" tabindex="-1" role="dialog" aria-labelleby="modal-3" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title text-success" id="exampleModalLabel"><i class="fas fa-users-cog"></i> INGRESAR</h5>
        <button type="button" class="close text-danger" data-dismiss="modal" aria-label="Close">
              <i class="far fa-times-circle"></i>
            </button>
      </div>
      <div class="modal-body">
        <div class="modal-body">
          <form action="./clases/login.php" method="POST">
            <div class="form-group">
              <label for="recipient-name" class="col-form-label text-muted"><i class="fas fa-user"></i> Usuario</label>
              <input type="text" name="user" class="form-control" placeholder="Tú Usuario Aquí..." required>
            </div>
            <div class="form-group">
              <label for="recipient-name" class="col-form-label text-muted"><i class="fas fa-user-lock"></i> Contraseña</label>
              <input type="password" name="pass" class="form-control" placeholder="Tú Contraseña Aquí..." required>
            </div>
            <div class=" modal-footer">
              <button type="submit" name="btnIngresar" class="btn btn-outline-success"><i class="fas fa-sign-in-alt"></i> Ingresar</button>
            </div>
          </form>
        </div>
      </div>
    </div>
  </div>
  </div

Мой код PHP:

<?php
    include '../conexion/conexion.php';
    error_reporting(0);
    $usuario = $_POST['user'];
    $contrasena = $_POST['pass'];
    $iniciar= $_POST['btnIngresar'];

   if (empty($usuario) || empty($contrasena)) {
    }else{ 
    if (isset($iniciar)) {
        $sql = "SELECT usuario, clave FROM admin WHERE usuario='$usuario' AND clave='$contrasena' ";
        $execute=$conexion->query($sql);
        $filas = $execute->fetch_row();
        if ($filas[0] == $usuario && $filas[1] == $contrasena) {
            $_SESSION['usuario']= $usuario;
            header("Location: ../blogI/blog.php");
        }else{
            echo "<script>
            alert ('Usuario o Clave Incorrectos');
            window.location = '../index.php';       
        </script>";
        }
    }
    }
?>

Сейчас страница, где он направляет меня, когда я инициализирую сеанс:

<?php include ("../conexion/conexion.php");?>
<?php   include ("includes/header.php");?>

<div class="container">
<?php if (isset($_SESSION['message'])){?>
    <div class="alert alert-<?= $_SESSION['message_typed'] ?> alert-dismissible fade show" role="alert">
    <?= $_SESSION['message'] ?>
   <button type="button" class="close" data-dismiss="alert" aria-label="Close">
       <span aria-hidden="true">&times;</span>
    </button>
    </div>
<?php session_unset(); }?>
<form action="save.php" method="POST"  enctype='multipart/form-data' name="formblog">
  <div class="form-group row">
    <label for="colFormLabelLg" class="col-sm-2 col-form-label col-form-label-lg">Titulo Del Articulo</label>
    <div class="col-sm-10">
      <input type="text" class="form-control form-control-lg" placeholder="titulo del articulo" name="title" value="">
    </div>
  </div>
  <div class="form-group row">
    <label for="colFormLabel" class="col-sm-2 col-form-label col-form-label-lg">Autor</label>
    <div class="col-sm-10">
      <input type="text" class="form-control" placeholder="Autor" name="autor"value="">
    </div>
  </div>
  <div class="form-group row">
    <label for="colFormLabelLg" class="col-sm-2 col-form-label col-form-label-lg">Imagen</label>
    <div class="col-sm-10">
    <input type="file" class="form-control-file" name="img">
    </div>
  </div>
  <div class="form-group row">
    <label for="colFormLabelLg" class="col-sm-2 col-form-label col-form-label-lg">Articulo</label>
    <div class="col-sm-10">
    <textarea type="text" class="form-control" id="txtArticle" placeholder="Introduzca su texto Aquí..." name="articulo"></textarea>
    </div>
  </div>
    <input class='btn btn-outline-primary' name='btnGuardar' type='submit' value="Publicar Articulo">
</form>

<script>
  (function(){
    var formulario = document.getElementsByName('formblog')[0],
      elementos = formulario.elemnts,
      boton = document.getElementById('btnGuardar');

      var validarTextArea = function(e){
        if (formulario.articulo.value.length <=200) {
          alert ("El Articulo debe tener mas de 200 caracteres o llena todos los campos :(");
          window.location = 'blog.php';
          e.preventDefault();
        }else{
          if (formulario.articulo.value.length > 500) {
            alert ("Limite permitido en el articulo hasta 500 caracteres o llena todos los campos :(");
            window.location = 'blog.php';
            e.preventDefault();
          }
        }
      };
        var validar = function(e){
        validarTextArea(e);
    };
      formulario.addEventListener("submit",validar);

  }())
</script>

<div class="container">
<table class="table table-bordered">
                <thead>
                    <tr>
                        <th>Fecha</th>
                        <th>Titulo</th>
                        <th>Autor</th>
                        <th>Contenido</th>
                        <th>Acciones</th>
                    </tr>
                </thead>
                <tbody>
                    <?php
                        $query = "SELECT * FROM articulo";
                        $resul = mysqli_query($conexion,$query);
                        while ($row = mysqli_fetch_array($resul)) { ?>
                            <tr>
                                <td><?php echo $row['fecha']?></td>
                                <td><?php echo $row['titulo_articulo']?></td>
                                <td><?php echo $row['autor_articulo']?></td>
                                <td><?php echo $row['contenido']?></td>
                                <td>
                                    <a href="edit.php?id=<?php echo $row['id_articulo']?>" class="btn btn-outline-success"><i class="far fa-edit"></i>
                                    </a>
                                    <a href="delete.php?id=<?php echo $row['id_articulo']?>" class="btn btn-outline-danger"><i class="far fa-trash-alt"></i>
                                    </a>
                                </td>
                            </tr>
                        <?php }
                    ?>
                </tbody>
            </table>
</div>
</div>

<?php include ("includes/footer.php"); ?> 

И это мой header, где у меня есть сеанс:

<?php
  error_reporting(0); 
  session_start();
  if (empty($_SESSION['usuario'])) {
      header("Location:../index.php");
  }
  ?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>AGROCONTABLE</title>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
    <script src="https://kit.fontawesome.com/a3a8d3af24.js"></script>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light" id="navbar">
    <a class="navbar-brand" href="#">
      <img src="../img/logoIcono.ico" width="70" height="70" class="d-inline-block align-top" alt="">
    </a>
  <strong class="navbar-brand" href="#" id="textos">AGROCONTABLE</strong><br>
  <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
    <span class="navbar-toggler-icon"></span>
  </button>

  <div class="collapse navbar-collapse" id="navbarSupportedContent">
  <ul class="navbar-nav mr-auto">
    <li class="nav-item" id="cambio">
        <a class="nav-link">Gestiona tu Produccion Agropecuaria</a>
    </li>
  </ul>
  <form class="form-inline my-2 my-lg-0" acttion="nabvarBlog.php" method="POST">
    <a class="mr-sm-2"><i class="far fa-user"></i><?php echo "Bienvenido $_SESSION[usuario]";?></a>
    <button class="form-control mr-sm-2 btn btn-outline-danger" type="submit" name="btnSalir"><i class="fas fa-sign-out-alt"></i> Salir</button>
  </form>
  </div>
</nav>
<?php
error_reporting(0); 
  $salir = $_POST['btnSalir'];
  if (isset($salir)) {
      session_destroy();
      header("Location:../index.php");
  }
 ?>
6
задан 22.07.2019, 16:36
0 ответов