Visualizzazione dei risultati da 1 a 5 su 5

Discussione: sessioni...

  1. #1
    Utente di HTML.it
    Registrato dal
    Nov 2004
    Messaggi
    25

    sessioni...

    Salve,

    potreste dare un'occhiata ai seguenti file??? Non capisco cosa non funziona... è un banalissimo esempio di utilizzo di sessioni...
    Nel file php.ini ho settatto la variabile session.save_path

    Tks

    prefs.html
    Codice PHP:
    <html>
    <
    head><title>Set Your Preferences</title></head>
    <
    body>
    <
    form action="prefs.php" method="POST">

    Background:
    <
    select name="background">
    <
    option value="black">Black</option>>
    <
    option value="white">White</option>
    <
    option value="red">Red</option>
    <
    option value="blue">Blue</option>
    </
    select>


    Foreground:
    <
    select name="foreground">
    <
    option value="black">Black</option>>
    <
    option value="white">White</option>
    <
    option value="red">Red</option>
    <
    option value="blue">Blue</option>
    </
    select>


    <
    input type="submit" value="Change Preferences">
    </
    form>
    </
    body>
    </
    html
    prefs.php
    Codice PHP:
    <?php
    $colors 
    = array('black' => '#000000',
                    
    'white' => '#ffffff',
                    
    'red'   => '#ff0000',
                    
    'blue'  => '#0000ff');

    session_start();
    session_register('bg');
    session_register('fg');             

    $bg_name $_POST['background'];
    $fg_name $_POST['foreground'];

    $bg $colors[$bg_name];
    $fg $colors[$fg_name];
    ?>
    <html>
    <head><title>Preferences Set</title></head>
    <body>
    Thank you. Your preferences have been changed to:

    Background: <?= $bg_name ?>

    Foreground: <?= $fg_name ?>

    Click [url="prefs-demo.php"]here[/url] to see the preferences in action.
    </body>
    </html>
    prefs_demo.php
    Codice PHP:
    <?php session_start() ?>
    <html>
    <head><title>Front Door</title></head>
    <body bgcolor="<?= $bg ?>" text="<?= $fg ?>">
    <h1>Welcome to the Store</h1>

    Would you like to [url="prefs1.html"]change your preferences?[/url]
    </body>
    </html>

  2. #2
    adesso faccio il parser umano..

    qualcosa di meno generico di "non funziona"..?

    che rrrori da eventualmente?
    ..quale comportamento inaspettato ha? ...etc etc

  3. #3
    Utente di HTML.it
    Registrato dal
    Nov 2004
    Messaggi
    25
    Originariamente inviato da }gu|do[z]{®©
    adesso faccio il parser umano..

    qualcosa di meno generico di "non funziona"..?

    che rrrori da eventualmente?
    ..quale comportamento inaspettato ha? ...etc etc
    in effetti...
    non vengono "passate" al file prefs-demo.php le variabili $bg e $fg

  4. #4
    Originariamente inviato da tex3
    in effetti...
    non vengono "passate" al file prefs-demo.php le variabili $bg e $fg
    session_start();
    session_register('bg');
    session_register('fg');


    diventa

    session_start();
    $_SESSION['bg'] = $bg;
    $_SESSION['fg'] = $fg;



  5. #5
    Utente di HTML.it
    Registrato dal
    Nov 2004
    Messaggi
    25
    Originariamente inviato da }gu|do[z]{®©
    session_start();
    session_register('bg');
    session_register('fg');


    diventa

    session_start();
    $_SESSION['bg'] = $bg;
    $_SESSION['fg'] = $fg;


    tks, il problema era dovuto al fatto che che register_globals era disattivato... ora funzia...

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.