Visualizzazione dei risultati da 1 a 2 su 2

Discussione: session sample

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

    utilizzo di sessioni...

    Salve,

    potreste dare un'occhiata ai seguenti file??? Non capisco cosa non funziona... è un banalissimo esempio di utilizzo di sessioni...

    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
    Utente di HTML.it
    Registrato dal
    Oct 2003
    Messaggi
    47
    Ciao
    Scusa ma potresti anche dirci qual'è il problema? Altrimenti mi è difficile sistemare un eventuale errore senza sapere qual'è


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.