Ver Mensaje Individual
  #2 (permalink)  
Antiguo 06/03/2013, 07:06
tonisaez
 
Fecha de Ingreso: mayo-2011
Mensajes: 9
Antigüedad: 13 años
Puntos: 0
Respuesta: Problema con varias sesiones en PHP

iniciarsesion.php:
Código PHP:
<?php require_once('../Connections/compra.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function 
GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
{
  
$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_ocolor$ocolor);
$query_r_noticias "SELECT *,DATE_FORMAT(fecha_noticias,'%d-%m-%Y') AS fecha_noticias FROM noticias";
$r_noticias mysql_query($query_r_noticias$ocolor) or die(mysql_error());
$row_r_noticias mysql_fetch_assoc($r_noticias);
$totalRows_r_noticias mysql_num_rows($r_noticias);

mysql_select_db($database_ocolor$ocolor);
$query_r_usuarios "SELECT * FROM usuarios";
$r_usuarios mysql_query($query_r_usuarios$ocolor) or die(mysql_error());
$row_r_usuarios mysql_fetch_assoc($r_usuarios);
$totalRows_r_usuarios mysql_num_rows($r_usuarios);

$colname_r_categorias "-1";
if (isset(
$_GET['id_categorias'])) {
  
$colname_r_categorias $_GET['id_categorias'];
}

$colname_r_productos "-1";
if (isset(
$_GET['id_categorias'])) {
  
$colname_r_productos $_GET['id_categorias'];
}
?>
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
  
session_start();
}

$loginFormAction $_SERVER['PHP_SELF'];
if (isset(
$_GET['accesscheck'])) {
  
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}

if (isset(
$_POST['textfield'])) {
  
$loginUsername=$_POST['textfield'];
  
$password=$_POST['textfield2'];
  
$MM_fldUserAuthorization "tipo_usuarios";
  
$MM_redirectLoginSuccess "redirigir.php";
  
$MM_redirectLoginFailed "iniciarsesionfallo.php";
  
$MM_redirecttoReferrer false;
  
mysql_select_db($database_ocolor$ocolor);
      
  
$LoginRS__query=sprintf("SELECT nombreusuario_usuarios, contrasena_usuarios, tipo_usuarios FROM usuarios WHERE nombreusuario_usuarios=%s AND contrasena_usuarios=%s",
  
GetSQLValueString($loginUsername"text"), GetSQLValueString($password"text")); 
   
  
$LoginRS mysql_query($LoginRS__query$ocolor) or die(mysql_error());
  
$loginFoundUser mysql_num_rows($LoginRS);
  if (
$loginFoundUser) {
    
    
$loginStrGroup  mysql_result($LoginRS,0,'tipo_usuarios');
    
    
//declare two session variables and assign them
    
$_SESSION['MM_Username'] = $loginUsername;
    
$_SESSION['MM_UserGroup'] = $loginStrGroup;          

    if (isset(
$_SESSION['PrevUrl']) && false) {
      
$MM_redirectLoginSuccess $_SESSION['PrevUrl'];    
    }
    
header("Location: " $MM_redirectLoginSuccess );
  }
  else {
    
header("Location: "$MM_redirectLoginFailed );
  }
}
?>

<!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>Orbicolor.com</title>
    <link href="../Css/estilos.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
    </style>
    <link href="../Css/estilos.css" rel="stylesheet" type="text/css" />
    <script src="../SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
    <link href="../SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
    <style type="text/css"></style>
</head>
<body>
<div id="contenedor">
    <div id="centro"><table width="550" border="0" cellspacing="0" cellpadding="0">
            <tr>
            <td height="15">&nbsp;</td>
            </tr>
            <tr>
            <td><strong>INICIAR SESI&Oacute;N</strong></td>
            </tr>
          <tr>
            <td><hr /></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td><form ACTION="<?php echo $loginFormAction?>" id="form2" name="form2" method="POST">
              <table width="550" border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td width="202" align="right"><span class="style8">Nombre de usuario:&nbsp;&nbsp; </span></td>
                  <td width="348"><span class="style6" id="sprytextfield1">
                    <label></label>
                    </span><span id="sprytextfield3">
                    <label>
                     <input type="text" name="textfield" id="textfield" />
                    </label>
                    <span class="textfieldRequiredMsg">Campo obligatorio</span></span></td>
                </tr>
                <tr>
                  <td align="right">&nbsp;</td>
                  <td><span class="style6"></span></td>
                </tr>
                <tr>
                  <td align="right"><span class="style8">Contrase&ntilde;a:&nbsp;&nbsp;</span></td>
                  <td><span id="sprytextfield2">
                    <label>
                    <input type="password" name="textfield2" id="textfield2" />
                    </label>
                    <span class="textfieldRequiredMsg">Campo obligatorio</span></span></td>
                </tr>
                <tr>
                  <td align="right">&nbsp;</td>
                  <td><span class="style6"></span></td>
                </tr>
                <tr>
                  <td align="right">&nbsp;</td>
                  <td><span class="style6">
                    <label>
                    <input type="submit" name="button2" id="button2" value="Iniciar Sesi&oacute;n" />
                    </label>
                  </span></td>
                </tr>
              </table>
              </form>    </td>
          </tr>
          <tr>
            <td>&nbsp;</td>
          </tr>
        </table>
    </div>
<script type="text/javascript">
<!--
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1");
var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2");
var sprytextfield3 = new Spry.Widget.ValidationTextField("sprytextfield3");
//-->
</script>
</div>
</body>
<!-- InstanceEnd --></html>
<?php
mysql_free_result
($r_noticias);

mysql_free_result($r_usuarios);
?>

Muchas gracias y un saludo!