Foros del Web » Programando para Internet » PHP »

Nesesito de su colaboracion con estas secciones en PHP y MYSQL

Estas en el tema de Nesesito de su colaboracion con estas secciones en PHP y MYSQL en el foro de PHP en Foros del Web. El problema que tengo es que cuando la gente se loguea correctamente puede volver a accerder a la pagina de logeo, lo que nesesito y ...
  #1 (permalink)  
Antiguo 30/12/2015, 21:47
 
Fecha de Ingreso: diciembre-2015
Ubicación: Medellín
Mensajes: 8
Antigüedad: 10 años, 9 meses
Puntos: 0
Exclamación Nesesito de su colaboracion con estas secciones en PHP y MYSQL

El problema que tengo es que cuando la gente se loguea correctamente puede volver a accerder a la pagina de logeo, lo que nesesito y si ustedes tan amables me ayuden, es que la gente cuando se loguee en 'login.php' y ya tengan su sección abierta no puedan volver a accerder a la pagina y los rediriga a la principal, ayuda pór favor, nesesito que me pasen el codigo, aqui les dejo el mio 'login.php':

Código PHP:
<?php require_once('../db/config.php'); ?>
<?php
if (!isset($_SESSION)) {
  
session_start();
}
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";

function 
isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { 
  
  
$isValid = False; 

  
  if (!empty(
$UserName)) { 

    
$arrUsers = Explode(",", $strUsers); 
    
$arrGroups = Explode(",", $strGroups); 
    if (
in_array($UserName, $arrUsers)) { 
      
$isValid = true; 
    } 
   
    if (
in_array($UserGroup, $arrGroups)) { 
      
$isValid = true; 
    } 
    if ((
$strUsers == "") && true) { 
      
$isValid = true; 
    } 
  } 
  return 
$isValid; 
}

$MM_restrictGoTo = "login.php";
if (!((isset(
$_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {   
  
$MM_qsChar = "?";
  
$MM_referrer = $_SERVER['PHP_SELF'];
  if (
strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
  if (isset(
$_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0) 
  
$MM_referrer .= "?" . $_SERVER['QUERY_STRING'];
  
$MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
  
header("Location: ". $MM_restrictGoTo); 
  exit;
}
?>
<?php 
require_once('../db/config.php'); ?>
<?php 
require_once('../db/config.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function 
GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (
PHP_VERSION < 6) {
    
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch (
$theType) {
    case 
"text":
      
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case 
"long":
    case 
"int":
      
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case 
"double":
      
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case 
"date":
      
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case 
"defined":
      
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return 
$theValue;
}
}

mysql_select_db($database_config, $config);
$query_user_admin = "SELECT Id, micro_p_us, micro_p_co FROM micro_p_user_adm";
$user_admin = mysql_query($query_user_admin, $config) or die(mysql_error());
$row_user_admin = mysql_fetch_assoc($user_admin);
$totalRows_user_admin = mysql_num_rows($user_admin);

if (!
function_exists("GetSQLValueString")) {
function 
GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (
PHP_VERSION < 6) {
    
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch (
$theType) {
    case 
"text":
      
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case 
"long":
    case 
"int":
      
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case 
"double":
      
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case 
"date":
      
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case 
"defined":
      
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return 
$theValue;
}
}

if ((isset(
$_GET['Id'])) && ($_GET['Id'] != "")) {
  
$deleteSQL = sprintf("DELETE FROM micro_p_post WHERE Id=%s",
                       
GetSQLValueString($_GET['Id'], "int"));

  
mysql_select_db($database_config, $config);
  
$Result1 = mysql_query($deleteSQL, $config) or die(mysql_error());

  
$deleteGoTo = "post.php";
  if (isset(
$_SERVER['QUERY_STRING'])) {
    
$deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?";
    
$deleteGoTo .= $_SERVER['QUERY_STRING'];
  }
  
header(sprintf("Location: %s", $deleteGoTo));
}

$maxRows_mostrar_post = 10;
$pageNum_mostrar_post = 0;
if (isset(
$_GET['pageNum_mostrar_post'])) {
  
$pageNum_mostrar_post = $_GET['pageNum_mostrar_post'];
}
$startRow_mostrar_post = $pageNum_mostrar_post * $maxRows_mostrar_post;

mysql_select_db($database_config, $config);
$query_mostrar_post = "SELECT * FROM micro_p_post";
$query_limit_mostrar_post = sprintf("%s LIMIT %d, %d", $query_mostrar_post, $startRow_mostrar_post, $maxRows_mostrar_post);
$mostrar_post = mysql_query($query_limit_mostrar_post, $config) or die(mysql_error());
$row_mostrar_post = mysql_fetch_assoc($mostrar_post);

if (isset(
$_GET['totalRows_mostrar_post'])) {
  
$totalRows_mostrar_post = $_GET['totalRows_mostrar_post'];
} else {
  
$all_mostrar_post = mysql_query($query_mostrar_post);
  
$totalRows_mostrar_post = mysql_num_rows($all_mostrar_post);
}
$totalPages_mostrar_post = ceil($totalRows_mostrar_post/$maxRows_mostrar_post)-1;
?>
  #2 (permalink)  
Antiguo 31/12/2015, 00:40
 
Fecha de Ingreso: diciembre-2015
Mensajes: 529
Antigüedad: 10 años, 9 meses
Puntos: 39
Respuesta: Nesesito de su colaboracion con estas secciones en PHP y MYSQL

No entiendo nada del código, y creo que estás poniendo parte del archivo innecesario. En fin, lo que yo hago es que cuando el usuario inicia sesión, recojo su id y su nombre, ya que de todos modos lo uso para personalizar mensajes. Así en cualquier sección coloco la condicional

Código PHP:
Ver original
  1. $varId =ID_USUARIO_LOGGEADO;
  2.  
  3. if ($varId == '' )
  4. redireccionar

Y listo :D

Etiquetas: backend, css, frontend, frontpage, mysql
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 09:32.