Ver Mensaje Individual
  #1 (permalink)  
Antiguo 03/12/2006, 10:05
charlierun
 
Fecha de Ingreso: enero-2006
Mensajes: 51
Antigüedad: 18 años, 3 meses
Puntos: 0
ayuda con sesiones

hola tengo un problema usando sesiones se ke las estoy guardando bien pero no se pk cuando llamo a otro php me dice (Notice: Undefined index: usuario in c:\archivos de programa\easyphp1-8\www\mywedding\fileupload_v1\1.php on line 5) vamos ke esa variable esta vacia.lo curioso es ke tengo 1 variable de sesion ke si funcionan bien,eso es lo ke me desconcierta.

Estoy seguro de ke lo ke hago es correcto y no entiendo pk no funciona. aki dejo el primer php ke extrae la id de una fila y la almacena en una variable de sesion llamada id esta al final del archivo
Código PHP:
<?php
include ("includes/config.php");
include (
"includes/funciones.php");
session_start();
unset(
$_SESSION['xml']);
unset(
$_SESSION['id']);
$usuario $_POST['username'];
$xmltime();
$fin=".xml";
$xmls$usuario.$xml.$fin;
$_SESSION['xml'] = $xmls;
 if (isset(
$_SESSION['usuario'])) {//esta variable de sesion funciona
$fotografo$_SESSION['usuario'];//esta variable de sesion funciona

$cnx=conectar();
 
$query2=mysql_query("INSERT INTO evento(id_evento,fotografo,cliente,fecha_alta,xml)VALUES "."('','$fotografo','$usuario','','$xmls')");
              }
              
mysql_close($cnx);
              
$cnx=conectar();           

$query3=mysql_query("SELECT id_evento FROM evento WHERE xml='$xmls'");
$row mysql_fetch_array($query3);
$id_usuario$row['id_evento'];            
$_SESSION['id']=$id_usuario;//aki no se ke pasa pero no guarda la variable de sesion.            
}                                     
?>
El siguiente php sirve para subir imagenes esto va genial pero cuando intento guardarlas en la bda usando la variable $_SESSION['id']=$id_usuario guarda todo en la bda y el campo id_evento ke se supone ke tiene ke ser el de la sesion se keda vacio.

Código PHP:
<?
include ("includes/config.php");
include (
"includes/funciones.php");

session_start();
$cnx=conectar();

$id$_SESSION['id'];//aki no guarda nada y no entiendo pk
if ($_FILES['Filedata']['name']) {
    
//$nuevoNombre = time().".jpg";


    
$size 150// the thumbnail height

    
$filedir 'hola/'// the directory for the original image
    
$thumbdir 'hola/'// the directory for the thumbnail image
    
$prefix 'small_';
    
$prefix1 'BIG_'// the prefix to be added to the original name

    
$maxfile '2000000';
    
$mode '0666';
    
    
$userfile_name $_FILES['Filedata']['name'];
    
$userfile_tmp $_FILES['Filedata']['tmp_name'];
    
$userfile_size $_FILES['Filedata']['size'];
    
$userfile_type $_FILES['Filedata']['type'];
    
    if (isset(
$_FILES['Filedata']['name'])) 
    {
        
$prod_img $filedir.$userfile_name;
           
$nuevoNombre time();
        
        
$prod_img_thumb $thumbdir.$prefix.$nuevoNombre.$userfile_name;
        
$prod_img_thumb1 $thumbdir.$prefix1.$nuevoNombre.$userfile_name;

        
move_uploaded_file($userfile_tmp$prod_img);
        
chmod ($prod_imgoctdec($mode));
        
        
$sizes getimagesize($prod_img);

        
$aspect_ratio $sizes[1]/$sizes[0]; 

        if (
$sizes[1] <= $sizes[0])
        {
            
$new_width 500;
            
$new_height 500*$aspect_ratio $sizes[1]/$sizes[0];
        }else{
            
$new_height 398;
            
$new_width 398*$aspect_ratio1 $sizes[0]/$sizes[1];
        }

            
$new_width1 100;
            
$new_height1 100;


        
$destimg=imagecreatetruecolor($new_width,$new_height)
            or die(
'Problem In Creating image');
        
$srcimg=imagecreatefromjpeg($prod_img)
            or die(
'Problem In opening Source Image');
        if(
function_exists('imagecopyresampled'))
        {
            
imagecopyresampled($destimg,$srcimg,0,0,0,0,$new_width,$new_height,ImageSX($srcimg),ImageSY($srcimg))
            or die(
'Problem In resizing');
        }else{
            
imagecopyresized($destimg,$srcimg,0,0,0,0,$new_width,$new_height,ImageSX($srcimg),ImageSY($srcimg))
            or die(
'Problem In resizing');
        }
        
imagejpeg($destimg,$prod_img_thumb,90)
        
//imagejpeg($destimg,$prod_img_thumb,90)
        //imagejpeg($destimg,"hola",90);
            
or die('Problem In saving');
            
        
imagedestroy($destimg);
        
        
        
        
$destimg1=imagecreatetruecolor($new_width1,$new_height1)
            or die(
'Problem In Creating image');
        
$srcimg1=imagecreatefromjpeg($prod_img)
            or die(
'Problem In opening Source Image');
        if(
function_exists('imagecopyresampled'))
        {
            
imagecopyresampled($destimg1,$srcimg1,0,0,0,0,$new_width1,$new_height1,ImageSX($srcimg1),ImageSY($srcimg1))
            or die(
'Problem In resizing');
        }else{
            
imagecopyresized($destimg1,$srcimg1,0,0,0,0,$new_width1,$new_height1,ImageSX($srcimg1),ImageSY($srcimg1))
            or die(
'Problem In resizing');
        }
        
imagejpeg($destimg1,$prod_img_thumb1,90)
        
//imagejpeg($destimg,$prod_img_thumb,90)
        //imagejpeg($destimg,"hola",90);
            
or die('Problem In saving');
            
        
imagedestroy($destimg1);
    }

@
unlink($prod_img); 


  
$query mysql_query("INSERT INTO imagenes (id_evento,galeria,image_small,image_big) VALUES "
                                           
."('$id','1','$prod_img_thumb1','$prod_img_thumb')");
}
?>
he probado a llamar un simple php ke haga un echo mostrando la variable de sesion despues de insertar el campo en la bda pero no me muestra nada.