Pagina 1 di 3 1 2 3 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 30

Discussione: problema login

  1. #1

    problema login

    al login mi visualizza questi problemucci..

    Notice: Undefined index: username in c:\programmi\easyphp1-8\www\enter.php on line 7
    Non hai fatto il login correttamente, mi spiace riprova
    Notice: Undefined index: username in c:\programmi\easyphp1-8\www\enter.php on line 17
    sto cercando di mettere in ordine lo script.

    posto il tutto:

    index3:

    <?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">

    <input type="password" value="password" size="20" maxlength="20" name="password">

    <input type="submit" value="Login" name="Submit">
    </form>
    </body>
    </html>


    login2:

    <?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);
    ?>


    enter:

    <?php
    session_start();
    //includo il file di Configurazione con session_start()) dentro
    include "config.php";
    //se esiste la variabile $_SESSION['username'] è loggato
    if($_POST['username'] != "")
    {
    echo "Benvenuto ".$_SESSION['username']." hai effettuato il login con successo
    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'];
    ?>

  2. #2

  3. #3
    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">

    <input type="password" value="password" size="20" maxlength="20" name="password">

    <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
    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

  4. #4
    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
    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

  5. #5

    manda il file

    manda il file
    che gli do un occhiata

    bye

  6. #6
    grazie!!
    posto il tutto

    step.php
    <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
    <meta name="author" content="Skyline">
    <title>Login</title>

    <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">

    <input type="password" value="password" size="20" maxlength="20" name="password">

    <input type="submit" value="Login" name="Submit">
    </form>
    </body>
    </html>

    login2.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']."'";
    $query=@mysql_query($sql) or die (mysql_error());
    echo "Benvenuto ".$_SESSION['username']." hai effettuato il login con successo
    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>";
    }
    ?>



    index0.php

    <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">

    <input type="password" value="password" size="20" maxlength="20" name="password">

    <input type="submit" value="Login" name="Submit">
    </form>
    </body>
    </html>

    questo è tutto..

    grazie davvero per la disponibilità

  7. #7
    Prova cosi:

    enter.php

    <?php
    session_start();
    //includo il file di Configurazione
    include "config.php";
    //se esiste la variabile $_SESSION['username'] è loggato

    if(isset($_SESSION['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']."'";
    $query=@mysql_query($sql) or die (mysql_error());
    echo "Benvenuto ".$_SESSION['username']." hai effettuato il login con successo
    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>";
    }
    ?>


    Perchè usi due pagine di form login uguali?

  8. #8
    ciao, grazie per la risposta..

    mi dice questo pero':

    Parse error: parse error in c:\programmi\easyphp1-8\www\enter.php on line 7

    questo: { da "fastidio"

  9. #9
    no scusa avevo dimenticato di chiudere una parentesi tonda (perchè usi due pagine login identiche??):

    <?php
    session_start();
    //includo il file di Configurazione
    include "config.php";
    //se esiste la variabile $_SESSION['username'] è loggato

    if(isset($_SESSION['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']."'";
    $query=@mysql_query($sql) or die (mysql_error());
    echo "Benvenuto ".$_SESSION['username']." hai effettuato il login con successo
    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>";
    }
    ?>

  10. #10
    ah, le pagine login sono 2 perchè in una ci provo dei cambiamenti..

    cmq adesso il problema della variabile non c'è piu', solo che non mi fa accedere al login con username e password che sono dentro...

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.