I can not log into my website, will not it be a circular reference?
I have index.php:
<html>
<head> <title>GESTION WEB</title> <meta charset="utf-8"/>
<link rel="stylesheet" type="text/css" href="css/stylos.css"/>
<meta charset="utf-8" />
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css" />
<link rel="stylesheet" href="bootstrap/css/bootstrap.css" />
<link rel="stylesheet" href="bootstrap/css/bootstrap-theme.min.css" />
<link rel="stylesheet" href="bootstrap/css/bootstrap-theme.css" />
<link rel="stylesheet" href="bootstrap/css/bootstrap-theme.css" />
<link rel="stylesheet" href="css/stylos.css" />
<script src="includes/jquery-3.3.1.js"></script>
<script src="bootstrap/js/bootstrap.js"></script>
</head>
<?php session_start(); ?>
<!-- * Login Ajax Php Mysql:
* Php mysql Ajax,
* Copyright 2015 bloguero-ec.
* Usese cómo mas le convenga no elimine estas líneas (http://www.bloguero-ec.com) *-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Login y Logout de usuarios con PHP y Ajax</title>
<link rel="stylesheet" type="text/css" href="stylesheet.css" />
<script type="text/javascript" src="views/login.js"></script>
</head>
<body><div id="allContent"><table cellpadding="0" cellspacing="0" border="0" height="100%" width="100%"><tr><td align="center" valign="middle" height="100%" width="100%">
<?php
require_once("routes.php");
if ( isset($_SESSION['username']) && isset($_SESSION['userid']) ){
call("template","index",0);
if (isset($_GET['controller'])&&isset($_GET['action'])) {
$controller=$_GET['controller'];
$action=$_GET['action'];
call($controller,$action,$id);
}else{
}
}
else{
echo '<form method="post" action="">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td>Usuario:</td>
<td><input type="text" name="login_username" id="login_username" /></td>
</tr>
<tr>
<td>Contraseña:</td>
<td><input type="password" name="login_userpass" id="login_userpass" /></td>
</tr>
<tr>
<td colspan="2" align="right"><span class="timer" id="timer"></span><button id="login_userbttn">Login</button></td>
</tr>
</table>
</form>';
}
?>
</span></span>
</td></tr></table></div></body>
</html>
And in login.js I have:
$.ajax({
type: 'POST',
url: 'views/procesologin.php',
data: 'login_username=' + $('#login_username').val() + '&login_userpass=' + $('#login_userpass').val(),
//si la sesion se inicia correctamente presentamos el mensaje
success:function(msj){
if ( msj == 1 ){
$('#alertBoxes').html('<div class="box-success"></div>');
$('.box-success').hide(0).html('Espera un momento…');
$('.box-success').slideDown(timeSlide);
setTimeout(function(){
window.location.href = "index.php?controller=template&action=index";
},(timeSlide + 500));
}
That is index.php- > login.js- > procesologin.php if it returns 1 I call back index.php but passing it to the controller template action index that is on the route sheet is the cover, but it is recharged login, that is, do not take the session, because everything is within the condition that this session is set but can it be?
It seems to me that when the page is reloaded the values are stepped on? doing var_dump returns null
Try redirecting to another script and passing any variable to require the file directly from the template:
window.location.href = "estado.php?valor=ee";
and I get: Notice: Undefined index: value in C: \ xampp \ htdocs \ gestionweb \ estado.php on line 4
That is, it does not send any value
I just discovered something: The content of template.php is as follows:
<html>
<body>
<?php session_start();?>
<div class="row" >
<nav class="dropdownmenu">
<ul>
<li><a href="">ABM</a>
<ul class="submenu" id="a">
<li ><a href="index.php?controller=cliente&action=index">Clientes</a></li>
<li ><a href="index.php?controller=articulo&action=index">Articulos</a></li>
<li ><a href="index.php?controller=proveedor&action=index">Proveedores</a></li>
<li ><a href="index.php?controller=envase&action=todos">Envases</a></li>
<li ><a href="index.php?controller=medida&action=index">Medidas</a></li>
<li ><a href="index.php?controller=canilla&action=index">Canillas</a></li>
</ul>
</li>
<li><a href="">Nuevo comprobante</a>
<ul class="submenu" id="b">
<li ><a href="index.php?controller=ticket&action=index">Ticket</a></li>
<!-- <li ><a href="index.php?controller=facturaa&action=index">Factura</a></li>-->
</ul>
</li>
<li><a href="#">Estado de cajas</a>
<ul class="submenu" id="c">
<li><a href="">Chequera</a></li>
<li><a href="">Cerrar caja</a></li>
<li><a href="">Posnet</a></li>
</ul>
</li>
<li><a href="">Nueva Venta</a>
<ul class="submenu" id="E">
<li><a href="index.php?controller=venta&action=index">Canilla</a></li>
<li><a href="index.php?controller=venta&action=cerrado">Producto</a></li>
</ul>
</li>
<li><a href="">Compra de stock</a>
<ul class="submenu" id="D">
<li><a href="index.php?controller=stock&action=index">Productos</a></li>
<li><a href="index.php?controller=stock&action=indexb">Barril</a></li>
<li><a href="index.php?controller=stock&action=canilla">Cambio de canilla</a></li>
</ul>
</li>
</ul>
<input type="button" class="btn btn-primary" value="Salir" onclick="<?php session_destroy(); header('Location: index.php');?>"/>
</nav>
</div>
</body>
</html>
If I delete everything and put some letters, it solves !!, shows those letters.
But what is it or what can I do?