• User Attivo

    dunque scrivo la prima parte del codice:

    step1foto.php
    <?php
    session_start();
    ?>
    <html>
    <head>
    <body bgcolor="black">
    <p align="center">

    <body onLoad="setTimeout('document.step1.submit();', 3000);">
    <form name="step1" action="step1.php" method="get">
    <title>Step1foto</title>
    </head>

    <?php
    include "config.php";
    $query = mysql_query("SELECT id_user, date FROM messaggi ORDER BY date DESC limit 1");
    while($riga = mysql_fetch_assoc($query))
    {
    $id_user = $riga["id_user"];
    }
    $id_cartella = substr(date('i'), -1, 1);
    if(!isset($_SESSION["id_cartella"]))
    $_SESSION["id_cartella"] = $id_cartella;

    $cartella = "fotos/".$id_cartella;
    $image_src ="fotos/" . $id_cartella . "fotos/"."1" . ".jpg";
    echo "<img src="$image_src">";

    ?>
    <?php
    $_SESSION['user'] = $_GET['user'];
    $_SESSION['gender'] = $_GET['gender'];
    $_SESSION['year'] = $_GET['year'];
    $_SESSION['month'] = $_GET['month'];
    $_SESSION['day'] = $_GET['day'];
    $_SESSION['country'] = $_GET['country'];
    ?>
    </body>
    </html>

    step1.php
    <?php
    session_start();
    $id_cartella = substr(date('i'), -1, 1);
    $_SESSION["id_cartella"] = $id_cartella;
    ?>

    <html>
    <head>

    <title>Step1</title>
    </head>

    <body onLoad="setTimeout('document.step2.submit();', 5000);">
    <form name="step2" action="step2.php" method="get">
    <fieldset>
    <BR><BR><BR> <BR> <font size="+4"> <legend> test arousal photo1</legend>
    <BR><BR><BR><BR>

    <font size="+1"> <input id="radio1" name="test_arousal_photo1" type="radio" value="-2" /><label for="radio1">it relaxes me a lot </label>

    <input id="radio2" name="test_arousal_photo1" type="radio" value="-1" /><label for="radio2">it relaxes me something</label>

    <input id="radio3" name="test_arousal_photo1" type="radio" value="0" /><label for="radio3">neither it relaxes me neither it activates me</label>
    <input id="radio4" name="test_arousal_photo1" type="radio" value="1" /><label for="radio4">it activates me something</label>
    <input id="radio5" name="test_arousal_photo1" type="radio" value="2" /> <label for="radio5">it activates me a lot</label></p>
    </fieldset>
    </form>
    </body>
    </html>

    step2.php

    <?php
    session_start();
    $id_cartella = substr(date('i'), -1, 1);
    $_SESSION["id_cartella"] = $id_cartella;
    ?>

    <html>
    <head>

    <title>Step1</title>
    </head>

    <body onLoad="setTimeout('document.step2.submit();', 5000);">
    <form name="step2" action="step2.php" method="get">

    <fieldset>
    <BR><BR><BR> <BR> <font size="+4"> <legend> test arousal photo1</legend>
    <BR><BR><BR><BR>

    <font size="+1"> <input id="radio1" name="test_arousal_photo1" type="radio" value="-2" /><label for="radio1">it relaxes me a lot </label>

    <input id="radio2" name="test_arousal_photo1" type="radio" value="-1" /><label for="radio2">it relaxes me something</label>

    <input id="radio3" name="test_arousal_photo1" type="radio" value="0" /><label for="radio3">neither it relaxes me neither it activates me</label>

    <input id="radio4" name="test_arousal_photo1" type="radio" value="1" /><label for="radio4">it activates me something</label>

    <input id="radio5" name="test_arousal_photo1" type="radio" value="2" /> <label for="radio5">it activates me a lot</label></p>
    </fieldset>

    </form>
    </body>
    </html>

    step2foto.php
    <?php
    session_start();
    $id_cartella = substr(date('i'), -1, 1);
    $_SESSION["id_cartella"] = $id_cartella;
    ?>
    <html>
    <head>
    <body bgcolor="black">
    <p align="center">

    <title>Step2foto</title>
    </head>

    <body onLoad="setTimeout('document.step2_1.submit();', 3000);">
    <form name="step2_1" action="step2_1.php" method="get">

    <body bgcolor="black">
    <p align="center">
    <?php

    include "config.php";

    $query = mysql_query("SELECT id_user, date FROM messaggi ORDER BY date DESC limit 1");
    while($riga = mysql_fetch_assoc($query))
    {
    $id_user = $riga['id_user'];
    }
    $id_cartella = substr(date('i'), -1, 1);

    if(!isset($_SESSION["id_cartella"]))
    $_SESSION["id_cartella"] = $id_cartella;

    $cartella = "fotos/".$id_cartella ;
    $image_src ="fotos/" . $id_cartella . "fotos/"."2" . ".jpg";

    echo "<img src="$image_src">";

    ?>

    ha ancora lo stesso problema che mi agiorna $id_cartella e mi passa alle foto con il numero successivo.
    ohibo'


  • User Attivo

    grazie,
    risolto cosi':
    <?php
    include "config.php";
    $query = mysql_query("SELECT id_user, date FROM messaggi ORDER BY date DESC limit 1");
    while($riga = mysql_fetch_assoc($query))
    {
    $id_user = $riga["id_user"];
    }
    if(!isset($_SESSION["id_cartella"]))
    $_SESSION["id_cartella"] = substr(date('i'), -1, 1);

    $cartella = "fotos/".$_SESSION["id_cartella"] ;
    $image_src ="fotos/" . $_SESSION["id_cartella"] . "fotos/"."1" . ".jpg";
    echo "<img src="$image_src">";
    ?>


  • Moderatore

    ovvio che poi dovevi usare la chiave SESSION 🙂


  • User Attivo

    si, session.
    grazie.


  • User Attivo

    Ciao a tutti,

    scusate l'intromissione, da dato che stiamo nel topic delle sessioni, come faccio a far trasformare un $_POST['input'] in un $_SESSION['input'] in pagina 1.php, poi cambiando pagina con redirect da 1.php a 2.php come faccio a prendere questo $_SESSION['input']?

    Grazie... 🙂

    :gthi:


  • Moderatore

    [php]
    session_start();
    echo $_SESSION['input'];
    [/php]
    nella pagina 2.php e lo ritrovi bello bello 🙂


  • User Attivo

    E io nella pagina 1.php posso fare redirect sia con php (funzione header()) sia con i meta tag (refresh)?

    :gthi:


  • Moderatore

    si tanto la chiave di sessione non si distrugge fino a quando o non si chiude il browser o non utilizzi il comando session_destroy();


  • User Attivo

    Posso anche usare dei form tra le pagine con la sessione senza perderla?

    Poi, per trasferire la chiave, esempio da una prima pagina fino a una terza, nella seconda si mette solo session_start()?

    Grazie,
    :gthi:


  • Moderatore

    si e poi si richiama la chiave di sessione che ti serve 🙂


  • User Attivo

    Ehm... ok ma la sessione viene mandata nell'url o no? (tipo $_GET o $_POST)

    :gthi:


  • Moderatore

    $_SESSION e basta....