Foros del Web » Programando para Internet » PHP »

problema con las sesiones

Estas en el tema de problema con las sesiones en el foro de PHP en Foros del Web. Tengo hecha una pagina en la que trabajo con sesiones para el carro de la compra y demas en la todo funciona correctamente. El problema ...
  #1 (permalink)  
Antiguo 30/04/2008, 11:19
 
Fecha de Ingreso: febrero-2007
Mensajes: 172
Antigüedad: 17 años, 2 meses
Puntos: 0
problema con las sesiones

Tengo hecha una pagina en la que trabajo con sesiones para el carro de la compra y demas en la todo funciona correctamente.
El problema es que ahora estoy haciendola nueva con un nuevo diseño,y en esta segunda version las sesiones no funcionan.
La unica diferencia entre una y otra esta en,por ejemplo,en la primera version los menus estan construidos en html mientras que en el nuevo diseño se construye a traves de funciones que llaman a la base de datos.Lo que es el código en si es el mismo solo he modificado el diseño.
Y a la version nueva le he añadido este codigo al principio:

<?
include("lib_carrito.php");
include("menus.php");
@session_start();
?>
y la inicializo asi:

Tu pedido consta de:<br>
<?

if (!isset($_SESSION["ocarrito"])){
$_SESSION["ocarrito"] = new carrito();
}
$_SESSION["ocarrito"]->numproductos();
echo "articulos";

?>
Pero con el diseño nuevo siempre crea una nueva no la mantiene.En cambio si accedo a la web con el nuevo diseño desde el antiguo funciona todo perfectamente,y ya no se a que se puede deber esto.
Por si no quedado muy calro pongo los enlaces por si alguien lo quiere comprobar
www.xeitopapeleria.com(diseño antiguo)
www.xeitopapeleria.com/incio_libreria.php(nuevo diseño)
  #2 (permalink)  
Antiguo 30/04/2008, 11:54
Avatar de eits  
Fecha de Ingreso: junio-2005
Ubicación: valladolid, yucatán
Mensajes: 1.655
Antigüedad: 18 años, 10 meses
Puntos: 88
Re: problema con las sesiones

prueba cambiando de lugar el session_start
Código PHP:
@session_start();
include(
"lib_carrito.php");
include(
"menus.php"); 
saludos.
__________________
El amor es la locura mas lucida que tiene el hombre.- Andres Henestrosa
la tristeza no existe, solo es... la ausencia de la felicidad.
  #3 (permalink)  
Antiguo 30/04/2008, 12:32
 
Fecha de Ingreso: marzo-2008
Mensajes: 171
Antigüedad: 16 años, 1 mes
Puntos: 0
Iframe y Sesion

Hola, de nuevo, estoy con varios problemitas estos dias, el que tengo ahora es que tengo una pagina que contiene un iframe en el que se carga el contenido.

La pagina tiene un acceso para usuarios registrados.

pueden verlo aca: http://190.17.18.210/uf/index_login2.php

A la derecha, como pueden ver dice: ACCESO y ahi se ingresa user y pass.

Prueben con:

USUARIO: foros
PASS: delweb

Una vez que ingresan bien user y pass, se carga en el iframe, un formulario para ingresar una noticia nueva y como pueden ver donde estaba el formulario de acceso aparece: Usted esta logueado como: ....

Lo que yo quiero que aparezca es: donde dice usted esta logueado como: que aparezca en nombre y apellido, correspondiente a al user que se logueo y en el campo del iframe para poner el autor, que aparezca tambien el nombre y apellido correspondiente.

la tabla que veriifca el usuario tiene 4 campos:

usuario
contrasena
nombre
apellido

Los datos que quisiera que aparezcan serian: nombre y apellido que correspondan a usuario.

Yo lo que puse es: " Ud. esta en el sistema como: {Session.MM_Username} " , pero lo que quisiera que aparezca es el nombre y apellido correspondiente a ese {Session.MM_Username} y que lo mismo aparezca por defecto en el campo "autor" del form.

Espero hayan entendido y me pueden ayudar.

Gracias y saludos!

Si no se entendio algo, por favor avisenme.
  #4 (permalink)  
Antiguo 30/04/2008, 13:00
 
Fecha de Ingreso: marzo-2008
Mensajes: 171
Antigüedad: 16 años, 1 mes
Puntos: 0
Re: [PROBLEMA] Iframe y Sesion

Logro hacer lo que busco en la parte que dice: "Ud esta en el sistema como..." , pero lo que no se es como "llevar" las variables al iframe, es como que se "pierden" ahi dentro.
  #5 (permalink)  
Antiguo 30/04/2008, 13:41
Avatar de HIa
HIa
 
Fecha de Ingreso: noviembre-2002
Ubicación: Cartago
Mensajes: 121
Antigüedad: 21 años, 5 meses
Puntos: 0
Re: Iframe y Sesion

Porque no usas sesisones?

session_start()
$_SESSION["nombre"] = $nombre_de_la_base_de_datos


y en el iframe

session_start();
$nombre = $_SESSION["nombre"];

otra cosa es que en la fecha puedes hacer un echo de date('m/d/Y') para ver la fecha

saludos
__________________
Siempre hay algo nuevo que aprender
  #6 (permalink)  
Antiguo 30/04/2008, 14:18
 
Fecha de Ingreso: marzo-2008
Mensajes: 171
Antigüedad: 16 años, 1 mes
Puntos: 0
Re: Iframe y Sesion

Sigo sin hacerlo funcionar, dejo los codigos de cada archivo:

El archivo con el formulario de LOGIN (index_login2.php):

Código PHP:
<?php require_once('Connections/uf.php'); ?>
<?php
mysql_select_db
($database_uf$uf);
$query_users "SELECT * FROM usuarios";
$users mysql_query($query_users$uf) or die(mysql_error());
$row_users mysql_fetch_assoc($users);
$totalRows_users mysql_num_rows($users);
?><?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['user'])) {
  
$loginUsername=$_POST['user'];
  
$password=$_POST['pass'];
  
$MM_fldUserAuthorization "";
  
$MM_redirectLoginSuccess "index_login_nn2.php";
  
$MM_redirectLoginFailed "index_login2.php";
  
$MM_redirecttoReferrer false;
  
mysql_select_db($database_uf$uf);
  
  
$LoginRS__query=sprintf("SELECT usuario, contraseña FROM usuarios WHERE usuario='%s' AND contraseña='%s'",
    
get_magic_quotes_gpc() ? $loginUsername addslashes($loginUsername), get_magic_quotes_gpc() ? $password addslashes($password)); 
   
  
$LoginRS mysql_query($LoginRS__query$uf) or die(mysql_error());
  
$loginFoundUser mysql_num_rows($LoginRS);
  if (
$loginFoundUser) {
     
$loginStrGroup "";
    
    
//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 HTML 4.01 Transitional//EN">
<html>
<head>

<style type="text/css">
<!--
body
{
    scrollbar-base-color: #FFFFFF;
    scrollbar-arrow-color: #FFFFFF;
    scrollbar-darkshadow-color: #FFFFFF;
    scrollbar-face-color: #FFFFFF;
    scrollbar-highlight-color: #FFFFFF;
    scrollbar-shadow-color: #FFFFFF;
    scrollbar-3dlight-color: #FFFFFF;
    margin-left: 0px;
    margin-top: -1px;
    margin-right: 0px;
    margin-bottom: 0px;
}
-->
</style>


<script language="javascript">

    window.defaultStatus = " ";
    document.title = "Universidad Favaloro";

</script>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
a:link {
    text-decoration: none;
    color: #ECE9D8;
}
a:visited {
    text-decoration: none;
    color: #ECE9D8;
}
a:hover {
    text-decoration: none;
    color: #FFFFFF;
}
a:active {
    text-decoration: none;
    color: #FFFFFF;
}
.letra {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 10px;
}
.campo {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 10px;
    background-color: #E8F2FC;
    border-top-width: 0px;
    border-right-width: 0px;
    border-bottom-width: 0px;
    border-left-width: 0px;
    border-top-style: none;
    border-right-style: none;
    border-bottom-style: none;
    border-left-style: none;
    border-top-color: #FFFFFF;
    border-right-color: #FFFFFF;
    border-bottom-color: #FFFFFF;
    border-left-color: #FFFFFF;
}
.Estilo2 {
    font-size: 10px;
    font-weight: bold;
    font-family: Arial, Helvetica, sans-serif;
    color: #409BF7;
}
-->
</style>
</head>

<body>
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
  <tr> 
    <td height="100%" align="center" valign="middle"><table border="0" cellpadding="0" cellspacing="0" width="995">
      <!-- fwtable fwsrc="sitio_bien_maxok_alto.png" fwbase="index.jpg" fwstyle="Dreamweaver" fwdocid = "1757951751" fwnested="0" -->
      <tr>
        <td><img src="imagenes/spacer.gif" width="255" height="1" border="0" alt=""></td>
        <td><img src="imagenes/spacer.gif" width="520" height="1" border="0" alt=""></td>
        <td><img src="imagenes/spacer.gif" width="43" height="1" border="0" alt=""></td>
        <td><img src="imagenes/spacer.gif" width="4" height="1" border="0" alt=""></td>
        <td><img src="imagenes/spacer.gif" width="2" height="1" border="0" alt=""></td>
        <td><img src="imagenes/spacer.gif" width="140" height="1" border="0" alt=""></td>
        <td><img src="imagenes/spacer.gif" width="2" height="1" border="0" alt=""></td>
        <td><img src="imagenes/spacer.gif" width="22" height="1" border="0" alt=""></td>
        <td><img src="imagenes/spacer.gif" width="7" height="1" border="0" alt=""></td>
        <td><img src="imagenes/spacer.gif" width="1" height="1" border="0" alt=""></td>
      </tr>
      <tr>
        <td colspan="9"><img name="index_r1_c1" src="imagenes/index_r1_c12b.jpg" width="995" height="86" border="0" alt=""></td>
        <td><img src="imagenes/spacer.gif" width="1" height="86" border="0" alt=""></td>
      </tr>
      <tr>
        <td rowspan="2" colspan="3"><img name="index_r2_c1" src="imagenes/index_r2_c1.jpg" width="818" height="56" border="0" alt=""></td>
        <td height="18" colspan="5" background="imagenes/index_r2_c4.jpg"><div align="center"><img src="file:///E|/Sitios Web/Favaloro/portada/imagenes/blank.gif" width="1" height="1"><span class="letra">
          <?php

    $dias 
= array("Domingo","Lunes","Martes","Mi&eacute;rcoles","Jueves","Viernes","S&aacute;bado");
    
$meses = array("Diciembre","Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre");
    echo 
$dias[date('w')];
    echo 
Date(" j");
    echo 
" de ";
    echo 
$meses[date('n')];
    echo 
" de ";
    echo 
Date("Y");
        
     
?>
        </span></div></td>
        <td rowspan="7"><img name="index_r2_c9" src="imagenes/index_r2_c9.jpg" width="7" height="511" border="0" alt=""></td>
        <td><img src="imagenes/spacer.gif" width="1" height="18" border="0" alt=""></td>
      </tr>
      <tr>
        <td rowspan="2" colspan="5"><img name="index_r3_c4" src="imagenes/index_r3_c4.jpg" width="170" height="58" border="0" alt=""></td>
        <td><img src="imagenes/spacer.gif" width="1" height="38" border="0" alt=""></td>
      </tr>
      <tr>
        <td rowspan="5"><img name="index_r4_c1" src="imagenes/index_r4_c1.jpg" width="255" height="455" border="0" alt=""></td>
        <td rowspan="4" align="center" valign="middle"><iframe align="right" width="512" height="415" id="cont" name="cont" frameborder="0" scrolling="Yes" src="contenido.html"></iframe></td>
        <td rowspan="5"><img name="index_r4_c3" src="imagenes/index_r4_c3.jpg" width="43" height="455" border="0" alt=""></td>
        <td><img src="imagenes/spacer.gif" width="1" height="20" border="0" alt=""></td>
      </tr>
      <tr>
        <td rowspan="4"><img name="index_r5_c4" src="imagenes/index_r5_c4.jpg" width="4" height="435" border="0" alt=""></td>
        <td colspan="3" valign="top"><img src="imagenes/calendario.png" width="144" height="125"></td>
        <td rowspan="4"><img name="index_r5_c8" src="imagenes/index_r5_c8.jpg" width="22" height="435" border="0" alt=""></td>
        <td><img src="imagenes/spacer.gif" width="1" height="125" border="0" alt=""></td>
      </tr>
      <tr>
        <td colspan="3" valign="top"><br>
          <img src="imagenes/acc.gif" width="75" height="13"><br>
          <table width="100%" cellspacing="0" cellpadding="0">
            <tr>
              <td width="93%" align="left" valign="bottom"><form action="<?php echo $loginFormAction?>" method="POST" name="acceso2" id="acceso2">
                  <input name="user" type="Text" class="campo" id="user" maxlength="50">
                  <input name="pass" type="password" class="campo" id="pass" maxlength="50">
                  <input type="image" name="imageField22" src="imagenes/enviar.gif">
                  <br>
              </form></td>
            </tr>
          </table></td>
        <td><img src="imagenes/spacer.gif" width="1" height="198" border="0" alt=""></td>
      </tr>
      <tr>
        <td rowspan="2"><img name="index_r7_c5" src="imagenes/index_r7_c5.jpg" width="2" height="112" border="0" alt=""></td>
        <td valign="bottom">&nbsp;</td>
        <td rowspan="2"><img name="index_r7_c7" src="imagenes/index_r7_c7.jpg" width="2" height="112" border="0" alt=""></td>
        <td><img src="imagenes/spacer.gif" width="1" height="77" border="0" alt=""></td>
      </tr>
      <tr>
        <td><img name="index_r8_c2" src="imagenes/index_r8_c2.jpg" width="520" height="35" border="0" alt=""></td>
        <td><img name="index_r8_c6" src="imagenes/index_r8_c6.jpg" width="140" height="35" border="0" alt=""></td>
        <td><img src="imagenes/spacer.gif" width="1" height="35" border="0" alt=""></td>
      </tr>
    </table></td>
  </tr>
</table>

</body>
</html>
<?php
mysql_free_result
($users);
?>
  #7 (permalink)  
Antiguo 30/04/2008, 14:19
 
Fecha de Ingreso: marzo-2008
Mensajes: 171
Antigüedad: 16 años, 1 mes
Puntos: 0
Re: Iframe y Sesion

El archivo al que me lleva si inicia sesion bien (index_login_nn2.php):

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

// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers$strGroups$UserName$UserGroup) { 
  
// For security, start by assuming the visitor is NOT authorized. 
  
$isValid False


  if (!empty(
$UserName)) { 

    
$arrUsers Explode(","$strUsers); 
    
$arrGroups Explode(","$strGroups); 
    if (
in_array($UserName$arrUsers)) { 
      
$isValid true
    } 
    
// Or, you may restrict access to only certain users based on their username. 
    
if (in_array($UserGroup$arrGroups)) { 
      
$isValid true
    } 
    if ((
$strUsers == "") && true) { 
      
$isValid true
    } 
  } 
  return 
$isValid
}

$MM_restrictGoTo "index_login2.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(
$QUERY_STRING) && strlen($QUERY_STRING) > 0
  
$MM_referrer .= "?" $QUERY_STRING;
  
$MM_restrictGoTo $MM_restrictGoTo$MM_qsChar "accesscheck=" urlencode($MM_referrer);
  
header("Location: "$MM_restrictGoTo); 
  exit;
}
?>
<?php
$colname_usuario 
"-1";
if (isset(
$_SESSION['MM_Username'])) {
  
$colname_usuario = (get_magic_quotes_gpc()) ? $_SESSION['MM_Username'] : addslashes($_SESSION['MM_Username']);
}
mysql_select_db($database_uf$uf);
$query_usuario sprintf("SELECT * FROM usuarios WHERE usuario = '%s'"$colname_usuario);
$usuario mysql_query($query_usuario$uf) or die(mysql_error());
$row_usuario mysql_fetch_assoc($usuario);
$totalRows_usuario mysql_num_rows($usuario);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>

<style type="text/css">
<!--
body
{
    scrollbar-base-color: #FFFFFF;
    scrollbar-arrow-color: #FFFFFF;
    scrollbar-darkshadow-color: #FFFFFF;
    scrollbar-face-color: #FFFFFF;
    scrollbar-highlight-color: #FFFFFF;
    scrollbar-shadow-color: #FFFFFF;
    scrollbar-3dlight-color: #FFFFFF;
    margin-left: 0px;
    margin-top: -1px;
    margin-right: 0px;
    margin-bottom: 0px;
}
-->
</style>


<script language="javascript">

    window.defaultStatus = " ";
    document.title = "Universidad Favaloro";

</script>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
a:link {
    text-decoration: none;
    color: #0000FF;
}
a:visited {
    text-decoration: none;
    color: #0000FF;
}
a:hover {
    text-decoration: none;
    color: #0000FF;
}
a:active {
    text-decoration: none;
    color: #0000FF;
}
.letra {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 10px;
}
.campo {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 10px;
    background-color: #E8F2FC;
    border-top-width: 0px;
    border-right-width: 0px;
    border-bottom-width: 0px;
    border-left-width: 0px;
    border-top-style: none;
    border-right-style: none;
    border-bottom-style: none;
    border-left-style: none;
    border-top-color: #FFFFFF;
    border-right-color: #FFFFFF;
    border-bottom-color: #FFFFFF;
    border-left-color: #FFFFFF;
}
.Estilo5 {font-family: Arial, Helvetica, sans-serif; font-size: 10px; color: #0000FF; }
body,td,th {
    color: #000000;
}
.Estilo6 {
    font-size: 12px;
    font-weight: bold;
}
.Estilo11 {
    font-size: 12px;
    font-family: Arial, Helvetica, sans-serif;
    color: #0000FF;
}
.Estilo13 {font-size: 10px}
.Estilo15 {font-family: Arial, Helvetica, sans-serif; font-size: 11px; color: #0000FF; }
-->
</style>
</head>

<body>
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
  <tr> 
    <td height="100%" align="center" valign="middle"><table border="0" cellpadding="0" cellspacing="0" width="995">
      <!-- fwtable fwsrc="sitio_bien_maxok_alto.png" fwbase="index.jpg" fwstyle="Dreamweaver" fwdocid = "1757951751" fwnested="0" -->
      <tr>
        <td><img src="imagenes/spacer.gif" width="255" height="1" border="0" alt=""></td>
        <td><img src="imagenes/spacer.gif" width="520" height="1" border="0" alt=""></td>
        <td><img src="imagenes/spacer.gif" width="43" height="1" border="0" alt=""></td>
        <td><img src="imagenes/spacer.gif" width="4" height="1" border="0" alt=""></td>
        <td><img src="imagenes/spacer.gif" width="2" height="1" border="0" alt=""></td>
        <td><img src="imagenes/spacer.gif" width="140" height="1" border="0" alt=""></td>
        <td><img src="imagenes/spacer.gif" width="2" height="1" border="0" alt=""></td>
        <td><img src="imagenes/spacer.gif" width="22" height="1" border="0" alt=""></td>
        <td><img src="imagenes/spacer.gif" width="7" height="1" border="0" alt=""></td>
        <td><img src="imagenes/spacer.gif" width="1" height="1" border="0" alt=""></td>
      </tr>
      <tr>
        <td colspan="9"><img name="index_r1_c1" src="imagenes/index_r1_c12b.jpg" width="995" height="86" border="0" alt=""></td>
        <td><img src="imagenes/spacer.gif" width="1" height="86" border="0" alt=""></td>
      </tr>
      <tr>
        <td rowspan="2" colspan="3"><img name="index_r2_c1" src="imagenes/index_r2_c1.jpg" width="818" height="56" border="0" alt=""></td>
        <td height="18" colspan="5" background="imagenes/index_r2_c4.jpg"><div align="center"><img src="file:///E|/Sitios Web/Favaloro/portada/imagenes/blank.gif" width="1" height="1"><span class="letra">
          <?php

    $dias 
= array("Domingo","Lunes","Martes","Mi&eacute;rcoles","Jueves","Viernes","S&aacute;bado");
    
$meses = array("Diciembre","Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre");
    echo 
$dias[date('w')];
    echo 
Date(" j");
    echo 
" de ";
    echo 
$meses[date('n')];
    echo 
" de ";
    echo 
Date("Y");
        
     
?>
        </span></div></td>
        <td rowspan="7"><img name="index_r2_c9" src="imagenes/index_r2_c9.jpg" width="7" height="511" border="0" alt=""></td>
        <td><img src="imagenes/spacer.gif" width="1" height="18" border="0" alt=""></td>
      </tr>
      <tr>
        <td rowspan="2" colspan="5"><img name="index_r3_c4" src="imagenes/index_r3_c4.jpg" width="170" height="58" border="0" alt=""></td>
        <td><img src="imagenes/spacer.gif" width="1" height="38" border="0" alt=""></td>
      </tr>
      <tr>
        <td rowspan="5"><img name="index_r4_c1" src="imagenes/index_r4_c1.jpg" width="255" height="455" border="0" alt=""></td>
        <td rowspan="4" align="center" valign="middle"><iframe align="right" width="512" height="415" id="cont" name="cont" frameborder="0" scrolling="Yes" src="nuevanoticia2.php"></iframe></td>
        <td rowspan="5"><img name="index_r4_c3" src="imagenes/index_r4_c3.jpg" width="43" height="455" border="0" alt=""></td>
        <td><img src="imagenes/spacer.gif" width="1" height="20" border="0" alt=""></td>
      </tr>
      <tr>
        <td rowspan="4"><img name="index_r5_c4" src="imagenes/index_r5_c4.jpg" width="4" height="435" border="0" alt=""></td>
        <td colspan="3" valign="top"><img src="imagenes/calendario.png" width="144" height="125"></td>
        <td rowspan="4"><img name="index_r5_c8" src="imagenes/index_r5_c8.jpg" width="22" height="435" border="0" alt=""></td>
        <td><img src="imagenes/spacer.gif" width="1" height="125" border="0" alt=""></td>
      </tr>
      <tr>
        <td colspan="3" align="left" valign="top"><br>
          <table width="100%" cellspacing="0" cellpadding="0">
              <tr>
                <td width="1" rowspan="3">&nbsp;</td>
                <td><div align="center" class="letra">Ud. est&aacute; en el sistema como: <span class="Estilo6"><br>
                  </span></div></td>
              </tr>
              <tr>
                <td height="2" align="center"><img src="imagenes/spacer.gif" width="1" height="1"></td>
              </tr>
              <tr>
                <td align="center" class="Estilo6"><span class="Estilo15"><?php echo $row_usuario['nombre']; ?><?php echo $row_usuario['apellido']; ?></span></td>
              </tr>
            </table>
            <br>
            <table width="100%" cellspacing="0" cellpadding="0">
              <tr>
                <td width="53%" align="right"><a href="<? session_destroy(); echo 'index_login2.php';?>"><u><img src="imagenes/logout.gif" width="12" height="12" border="0"></u></a></td>
                <td width="47%" align="right"> <span class="Estilo11"><span class="Estilo13">Cerrar Sesi&oacute;n </span></span></td>
              </tr>
            </table>            
            <p class="Estilo5"><a href="<? session_destroy(); echo 'index_login.php';?>"></a></p>          </td>
        <td><img src="imagenes/spacer.gif" width="1" height="198" border="0" alt=""></td>
      </tr>
      <tr>
        <td rowspan="2"><img name="index_r7_c5" src="imagenes/index_r7_c5.jpg" width="2" height="112" border="0" alt=""></td>
        <td valign="bottom">&nbsp;</td>
        <td rowspan="2"><img name="index_r7_c7" src="imagenes/index_r7_c7.jpg" width="2" height="112" border="0" alt=""></td>
        <td><img src="imagenes/spacer.gif" width="1" height="77" border="0" alt=""></td>
      </tr>
      <tr>
        <td><img name="index_r8_c2" src="imagenes/index_r8_c2.jpg" width="520" height="35" border="0" alt=""></td>
        <td><img name="index_r8_c6" src="imagenes/index_r8_c6.jpg" width="140" height="35" border="0" alt=""></td>
        <td><img src="imagenes/spacer.gif" width="1" height="35" border="0" alt=""></td>
      </tr>
    </table></td>
  </tr>
</table>

</body>
</html>
<?php
mysql_free_result
($usuario);
?>
  #8 (permalink)  
Antiguo 30/04/2008, 14:20
 
Fecha de Ingreso: marzo-2008
Mensajes: 171
Antigüedad: 16 años, 1 mes
Puntos: 0
Re: Iframe y Sesion

El archivo que tiene el formulario (nuevanoticia2.php):

Aca es es donde quiero que aparezca en el campo "AUTOR" el nombre de usuario y apellido que corresponde al nombre de usuario.

Código PHP:
<?php require_once('Connections/uf.php'); ?>
<?php
session_start
();


function 
GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
{
  
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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;
}

$editFormAction $_SERVER['PHP_SELF'];
if (isset(
$_SERVER['QUERY_STRING'])) {
  
$editFormAction .= "?" htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset(
$_POST["MM_insert"])) && ($_POST["MM_insert"] == "insertar_noticia")) {
  
$insertSQL sprintf("INSERT INTO noticias (autor, titulo, resumen, noticia, fecha) VALUES (%s, %s, %s, %s, %s)",
                       
GetSQLValueString($_POST['autor'], "text"),
                       
GetSQLValueString($_POST['titulo'], "text"),
                       
GetSQLValueString($_POST['resumen'], "text"),
                       
GetSQLValueString($_POST['noticia'], "text"),
                       
GetSQLValueString($_POST['fecha'], "text"));

  
mysql_select_db($database_uf$uf);
  
$Result1 mysql_query($insertSQL$uf) or die(mysql_error());
}

mysql_select_db($database_uf$uf);
$query_noticias_uf "SELECT * FROM noticias ORDER BY id ASC";
$noticias_uf mysql_query($query_noticias_uf$uf) or die(mysql_error());
$row_noticias_uf mysql_fetch_assoc($noticias_uf);
$totalRows_noticias_uf mysql_num_rows($noticias_uf);

$colname_usuarios "-1";
if (isset(
$_SESSION['MM_Username'])) {
  
$colname_usuarios = (get_magic_quotes_gpc()) ? $_SESSION['MM_Username'] : addslashes($_SESSION['MM_Username']);
}
mysql_select_db($database_uf$uf);
$query_usuarios sprintf("SELECT * FROM usuarios WHERE usuario = '%s'"$colname_usuarios);
$usuarios mysql_query($query_usuarios$uf) or die(mysql_error());
$row_usuarios mysql_fetch_assoc($usuarios);
$totalRows_usuarios mysql_num_rows($usuarios);
?><!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>Documento sin t&iacute;tulo</title>
<style type="text/css">
<!--
body,td,th {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
}
.letra {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 10px;
    list-style-position: inside;
    list-style-image: url((URL));
    list-style-type: circle;
}
.campo {
    border: 1px solid #CCF0FE;
    background-color: #FFFFFF;
}
.boton {
    background-color: #D8F3FE;
    border-top-style: solid;
    border-right-style: solid;
    border-bottom-style: solid;
    border-left-style: solid;
    border-top-color: #FFFFFF;
    border-right-color: #FFFFFF;
    border-bottom-color: #FFFFFF;
    border-left-color: #FFFFFF;
}
.fecha {
    color: #666666;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 10px;
    font-weight: normal;
}
.Estilo1 {
    font-size: 11px;
    font-weight: bold;
}
.Estilo4 {
    color: #666666;
    font-size: 10px;
}
.Estilo9 {color: #666666; font-size: 13px; }
-->
</style>
</head>

<body>
<table width="350" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td width="100%"><span class="Estilo1">Hoy es:</span><span class="fecha">  
      <?php

    $dias 
= array("Domingo","Lunes","Martes","Mi&eacute;rcoles","Jueves","Viernes","S&aacute;bado");
    
$meses = array("Diciembre","Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre");
    
$numero=Date(" j");
    echo 
$dias[date('w')];
    echo 
Date(" j");
    echo 
" de ";
    echo 
$meses[date('n')];
    echo 
" de ";
    echo 
Date("Y");
    
     
?>
    </span></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td height="20" align="center" bgcolor="#D8F3FE"><span class="Estilo4">Complete el siguiente formulario para publicar una nueva noticia </span></td>
  </tr>
  <tr>
    <td align="right">&nbsp;</td>
  </tr>
</table>
<table width="350" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="331" valign="top"><form id="insertar_noticia" name="insertar_noticia" method="POST" action="<?php echo $editFormAction?>">
      <table width="100%" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td width="68" height="30" align="right"><span class="Estilo9">Fecha: </span></td>
          <td width="4" height="30" align="right">&nbsp;</td>
          <td width="229" height="30"><span class="letra">
            <label></label>
            <input name="fecha" type="text" class="campo" id="fecha" value="DD/MM/AAAA" />
          </span></td>
        </tr>
        <tr>
          <td width="68" height="30" align="right" valign="middle"><span class="Estilo9">Autor:</span></td>
          <td width="4" height="30" align="right" valign="middle">&nbsp;</td>
          <td width="229" height="30" valign="middle"><span class="letra">
            <input name="autor" type="text" class="campo" id="autor" />
     
    </span></td>
        </tr>
        <tr>
          <td width="68" height="30" align="right"><span class="Estilo9">Titulo:</span></td>
          <td width="4" height="30" align="right">&nbsp;</td>
          <td width="229" height="30"><span class="letra">
            <input name="titulo" type="text" class="campo" id="titulo" />
          </span></td>
        </tr>
        <tr>
          <td width="68" height="30" align="right" valign="top"><span class="Estilo9"><br />
            Resumen: </span></td>
          <td width="4" height="30" align="right">&nbsp;</td>
          <td width="229" height="30"><label> <br />
            <textarea name="resumen" cols="30" rows="4" class="campo" id="resumen"></textarea>
          </label></td>
        </tr>
        <tr>
          <td width="68" height="30" align="right" valign="top"><span class="Estilo9"><br />
            Noticia: </span></td>
          <td width="4" height="30" align="right">&nbsp;</td>
          <td width="229" height="30"><label> <br />
            <textarea name="noticia" cols="30" rows="9" class="campo" id="noticia"></textarea>
          </label></td>
        </tr>
        <tr>
          <td height="30" align="right" valign="top">&nbsp;</td>
          <td height="30" align="right">&nbsp;</td>
          <td height="30"><label>
            <input name="Submit" type="submit" class="boton" value="Enviar" />
          
    
          </label></td>
        </tr>
      </table>
        <input type="hidden" name="MM_insert" value="insertar_noticia">
    </form>
    </td>
  </tr>
</table>
</body>
</html>
<?php
mysql_free_result
($noticias_uf);

mysql_free_result($usuarios);
?>
  #9 (permalink)  
Antiguo 30/04/2008, 16:33
 
Fecha de Ingreso: febrero-2007
Mensajes: 172
Antigüedad: 17 años, 2 meses
Puntos: 0
Re: problema con las sesiones

cambiando el lugar del session_start me da este error:
Fatal error: Unknown(): The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition &lt;b&gt;carrito&lt;/b&gt; of the object you are trying to operate on was loaded _before_ the session was started
  #10 (permalink)  
Antiguo 30/04/2008, 16:44
Avatar de eits  
Fecha de Ingreso: junio-2005
Ubicación: valladolid, yucatán
Mensajes: 1.655
Antigüedad: 18 años, 10 meses
Puntos: 88
Re: problema con las sesiones

creo que el session_start debe de ir debajo de lib_carrito
Código PHP:
include("lib_carrito.php");
@
session_start();
include(
"menus.php"); 
checalo y comentas.

saludos.
__________________
El amor es la locura mas lucida que tiene el hombre.- Andres Henestrosa
la tristeza no existe, solo es... la ausencia de la felicidad.
  #11 (permalink)  
Antiguo 30/04/2008, 17:29
 
Fecha de Ingreso: marzo-2008
Mensajes: 171
Antigüedad: 16 años, 1 mes
Puntos: 0
Re: Iframe y Sesion

SOLUCIONADO!

MIL GRACIAS A eits
  #12 (permalink)  
Antiguo 01/05/2008, 06:06
 
Fecha de Ingreso: febrero-2007
Mensajes: 172
Antigüedad: 17 años, 2 meses
Puntos: 0
Re: problema con las sesiones

Si coloco el session_sart entre lib_carrito.php y menus.php no me da ningun error porque dentro de menus.php no hay nada que afecte a la sesion,son sol funciones para crear los menus.
Pero sigo con el mismo problema de que la sesion no la mantiene y siempre crea una nueva
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 08:45.