Ver Mensaje Individual
  #1 (permalink)  
Antiguo 11/08/2013, 17:10
programatecs3
 
Fecha de Ingreso: agosto-2013
Ubicación: lima
Mensajes: 1
Antigüedad: 10 años, 9 meses
Puntos: 0
Como puedo extraer el valor de mi session en PHP

Estos es un pequeño ejemplo para que me puedan ayudar!....

Esta es una pagina de INICIO DE SESSION:::: se llama "index.php"


Código PHP:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title></title>
    </head>
    <body>
        <form action="ingresar.php" method="post">
            <table>
                <tr>
                    <td>Hola:
                <?php
                            session_start
();
                            echo 
$_SESSION['nombre'];///AQUI QUIERO EXTRAER EL VALOR DEL NOMBRE
                
?>

                   </td>
                    <td>
                        <input type="text" name="nombre"><br><br>
                        <input type="text" name="contra"><br><br>
                        <input type="submit" value="INGRESAR">
                    </td>

                </tr>

            </table>
            
        </form>
    </body>
</html>
// A TRAVEZ DEL FORMULARIO PARA VALIDAR EL NOMBRE Y CONTRASEÑA VOY A ESTA OTRA PAGINA QUE SE LLAMA "ingresar.php". bueno lo estoy haxiendo con un nombre y una contraseñas dadas como se ve ahi.... lo que hago despues de validar ello es redireccionarlo a la misma pagina anterior y recien leer el valor que le asigo auqUI Y ENVIARLO A MI PAGINA ANTERIOR QUE SE LLAMA ""index.php"


Código PHP:
<?php
session_start
();

if(
$_POST['nombre']=="leo"&&$_POST['contra']=="1234")
{
    
$_SESSION['nombre']=$_POST['nombre'];
    
session_cache_limiter('nocache,private');
    
header('Location: index.php');
}
?>

BUENO PARA SER CIETO SI LLEGO A EXTRAER EL VALOR PERO EN LA PAGINA INDEX,PHP ME SALE ESTO..... Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\AppServ\www\PhpProject2\index.php:2) in C:\AppServ\www\PhpProject2\index.php on line 3

e identifica a la linea de codigo que esta en INDEX.PHP especificando cuando declaro:::: session_start();


Espero sus respuestas!!!