• User Attivo

    ho cambiato cosi' enter.php

    <?php
    session_start();
    //includo il file di Configurazione con session_start()) dentro
    include "config.php";
    //se esiste la variabile $_SESSION['username'] è loggato
    if(isset($_POST['username']))
    {
    echo "Benvenuto ".$_POST['username']." hai effettuato il login con successo<br>can see the final statistics <a href="finalstat.php">stat</a>.";
    }
    //Altrimenti non è loggato
    else
    {
    echo "Non hai fatto il login correttamente, mi spiace <a href="index3.php">riprova</a> ";
    }
    ?>

    ma lo stesso nn mi fa loggare


  • ModSenior

    Aspetta un attimo 😄
    quella pagina in pratica è il login o la pagina dove reindirizzi l'utente che si logga?
    se è la pagina dove reindirizzi devi usare $_SESSION


  • User Attivo

    si, è il reindirizzamento del login.. dove cambio?
    sono impanicato ...


  • ModSenior

    allora nel login imposti la sessione quindi nella pagina enter devi usare $_SESSION

    visto che $_POST non centra nulla...


  • User Attivo

    messo tutto in $_SESSION, mi dice questo:

    Non hai fatto il login correttamente, mi spiace riprova
    Notice: Undefined index: username in c:\programmi\easyphp1-8\www\enter.php on line 17

    <?php
    session_start();
    //includo il file di Configurazione con session_start()) dentro
    include "config.php";
    //se esiste la variabile $_SESSION['username'] è loggato
    if(isset($_SESSION['username']))
    {
    echo "Benvenuto ".$_SESSION['username']." hai effettuato il login con successo<br>can see the final statistics <a href="finalstat.php">stat</a>.";
    }
    //Altrimenti non è loggato
    else
    {
    echo "Non hai fatto il login correttamente, mi spiace <a href="index3.php">riprova</a> ";
    }
    echo $_SESSION['username'];
    ?>


  • User Attivo

    posto ancora lo script nella speranza che qualcuno mi aiuti:

    <?php
    session_start();
    ?>
    <html>
    <head>
    <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
    <meta name="author" content="Skyline">
    <title>Login</title>
    </head>
    <body>
    <form action="login2.php" method="post" enctype="application/x-www-form-urlencoded" name="login">
    <input type="text" value="username" size="20" maxlength="20" name="username"><br>
    <input type="password" value="password" size="20" maxlength="20" name="password"><br>
    <input type="submit" value="Login" name="Submit">
    </form>
    </body>
    </html>

    <?php
    session_start();
    //includo il file di Configurazione con session_start()) dentro
    include "config.php";
    //Eseguo una query nella tabella messaggi verificando se esiste l'username con quella password
    $username="";
    $psw="";
    $username=$_POST['username'];
    $psw=md5($_POST['password']);
    $query = mysql_query("SELECT username FROM messaggi WHERE username='$username' AND password='$psw'") or die (mysql_error());
    $veruser = mysql_num_rows ($query);
    //se esegue la query entra nell'IF
    if($veruser !== 0)
    {
    //metto l'username nella variabile di sessione "username"
    session_start();
    $_SESSION['username'] = $_POST['username'];
    //Faccio il redirect nella pagine enter.php
    echo "<script>
    window.location = "enter.php"
    </script>";
    }
    else
    {
    //Faccio il redirect nella pagine enter.php
    echo "<script>
    window.location = "enter.php"
    </script>";
    }
    @mysql_close($connection);
    ?>

    <?php
    session_start();
    //includo il file di Configurazione con session_start()) dentro
    include "config.php";
    //se esiste la variabile $_SESSION['username'] è loggato
    if(isset($_SESSION['username']))
    {
    echo "Benvenuto ".$_SESSION['username']." hai effettuato il login con successo<br>can see the final statistics <a href="finalstat.php">stat</a>.";
    }
    //Altrimenti non è loggato
    else
    {
    echo "Non hai fatto il login correttamente, mi spiace <a href="index3.php">riprova</a> ";
    }
    echo $_SESSION['username'];
    ?>

    risposta:
    Non hai fatto il login correttamente, mi spiace riprova
    Notice: Undefined index: username in c:\programmi\easyphp1-8\www\enter.php on line 17


  • User Attivo

    aiutino per favore...ditemi che c'ha sto script senno' lo strozzo!!!:fumato:


  • ModSenior

    La riga 17 è questa: echo $_SESSION['username']; ?
    se è questa la sessione non è definita e quindi il problema è nella creazione della sessione


  • User Attivo

    ma io ho già una sessione aperta...come posso crearne un'altra..quindi forse per questo che nn funzia?


  • ModSenior

    ma nel file di login questo
    session_start();

    quante volte lo hai messo? O.o


  • User Attivo

    session_start(); c'è due volte,:bho:

    so che è sbagliato e di solito restituisce che già una sessione è aperta, ma nn dice nulla e se lo tolgo nn cambia nulla...😢


  • User Attivo

    aiutino?


  • User Attivo

    ho cambiato qualcosa ma il risultato non cambia.. nn mi riconosce quando mi loggo...

    dunque:

    login.php

    <?php
    session_start();
    //includo il file di Configurazione con session_start()) dentro
    include "config.php";
    //Eseguo una query nella tabella messaggi verificando se esiste l'username con quella password
    $username="";
    $psw="";
    $username=$_POST['username'];
    $psw=md5($_POST['password']);
    $query = mysql_query("SELECT username FROM messaggi WHERE username='$username' AND password='$psw'") or die (mysql_error());
    $veruser = mysql_num_rows ($query);
    //se esegue la query entra nell'IF
    if($veruser !== 0)
    {
    //metto l'username nella variabile di sessione "username"
    $_SESSION['username'] = $_POST['username'];
    //Faccio il redirect nella pagine enter.php
    echo "<script>
    window.location = "enter.php"
    </script>";
    }
    else
    {
    //Faccio il redirect nella pagine enter.php
    echo "<script>
    window.location = "enter.php"
    </script>";
    }
    @mysql_close($connection);
    ?>

    enter.php
    <?php
    session_start();
    //includo il file di Configurazione
    include "config.php";
    //se esiste la variabile $_SESSION['username'] è loggato
    if($_SESSION['username'] = $_POST['username'] != "")
    {
    $sql="UPDATE
    messaggi SET user='".$_SESSION['id_user']."',
    gender SET user='".$_SESSION['gender']."',
    year SET user='".$_SESSION['year']."',
    month SET user='".$_SESSION['month']."',
    day SET user='".$_SESSION['day']."',
    country SET user='".$_SESSION['country']."',
    test_arousal_photo1 SET user='".$_SESSION['test_arousal_photo1']."',
    test_valence_photo1 SET user='".$_SESSION['test_valence_photo1']."',
    test_arousal_photo2 SET user='".$_SESSION['test_arousal_photo2']."',
    test_valence_photo2 SET user='".$_SESSION['test_valence_photo2']."',
    test_arousal_photo3 SET user='".$_SESSION['test_arousal_photo3']."' ,
    test_valence_photo3 SET user='".$_SESSION['test_valence_photo3']."',
    test_arousal_photo4 SET user='".$_SESSION['test_arousal_photo4']."',
    test_valence_photo4 SET user='".$_SESSION['test_valence_photo4']."',
    test_arousal_photo5 SET user='".$_SESSION['test_arousal_photo5']."',
    test_valence_photo5 SET user='".$_SESSION['test_valence_photo5']."',
    test_arousal_photo6 SET user='".$_SESSION['test_arousal_photo6']."',
    test_valence_photo6 SET user='".$_SESSION['test_valence_photo6']."',
    test_arousal_photo7 SET user='".$_SESSION['test_arousal_photo7']."' ,
    test_valence_photo7 SET user='".$_SESSION['test_valence_photo7']."',
    test_arousal_photo8 SET user='".$_SESSION['test_arousal_photo8']."',
    test_valence_photo8 SET user='".$_SESSION['test_valence_photo8']."',
    test_arousal_photo9 SET user='".$_SESSION['test_arousal_photo9']."',
    test_valence_photo9 SET user='".$_SESSION['test_valence_photo9']."',
    test_arousal_photo10 SET user='".$_SESSION['test_arousal_photo10']."',
    test_valence_photo10 SET user='".$_SESSION['test_valence_photo10']."',
    WHERE username='".$_SESSION['username']."'";
    or die (mysql_error());
    echo "Benvenuto ".$_SESSION['username']." hai effettuato il login con successo<br>Puoi effettuare il <a href="logout.php">logout</a>.";
    }
    //Altrimenti non è loggato
    else
    {
    echo "Non hai fatto il login correttamente, mi spiace <a href="index0.php">riprova</a>";
    }
    ?>

    risultato:
    non mi riconosce quando mi loggo e ..
    Notice: Undefined index: username in c:\programmi\easyphp1-8\www\enter.php on line 7
    Non hai fatto il login correttamente, mi spiace riprova