Pagina 2 di 2 primaprima 1 2
Visualizzazione dei risultati da 11 a 15 su 15
  1. #11

    Ultimissima poi ........

    Tutti a letto con le
    dovute modifiche funziona
    anche quell'altro praticamente
    metti tutti i valori name (key)
    e pass (value) e nel'if
    controlli se l'array con quel
    nome ha quella password.
    $fp = file("log.dat"); // leggo il file
    foreach ($fp as $line) {
    $info = explode("|", $line);
    $name = trim($info[0]);
    $password = trim($info[1]);
    $arr[$name] = $password;
    }
    if(isset($_POST['name']))
    {
    $postName = $_POST['name'];
    $postPass = $_POST['pass'];
    if(empty($_POST['name']) || empty($_POST['pass']))
    {
    echo "Tutti i campi sono obbligatori";
    }
    else
    {
    if($arr[$postName]==$postPass)
    {
    echo "Good !";
    }
    else
    {
    echo "Nice Try ";
    }
    }
    }
    ?>
    <form method="post" name="frm">
    <input name="name" type="text">

    <input name="pass" type="password">

    <input name="submit" type="submit" value="submit">
    </form>
    A nanna
    Without faith, nothing is possible. With it, nothing is impossible
    http://ilwebdifabio.it

  2. #12

    .........

    Ultimissima al posto di '|'
    usa "\t" è + sicuro in fase
    di registrazione metti che qc
    metta un segno '|' ti può
    combinare dei casini se usi
    "\t" no.
    Without faith, nothing is possible. With it, nothing is impossible
    http://ilwebdifabio.it

  3. #13

    Re: Ultimissima poi ........

    Ciao whisher

    Guardando questo script non riesco a capire alcune cose:

    $fp = file("log.dat"); // leggo il file
    foreach ($fp as $line) {
    $info = explode("|", $line);
    $name = trim($info[0]);
    $password = trim($info[1]);
    $arr[$name] = $password;
    }
    if(isset($_POST['name']))
    {
    $postName = $_POST['name'];
    $postPass = $_POST['pass'];
    if(empty($_POST['name']) || empty($_POST['pass']))
    {
    echo "Tutti i campi sono obbligatori";
    }
    else
    {
    if($arr[$postName]==$postPass)
    {
    echo "Good !";
    }
    else
    {
    echo "Nice Try ";
    }
    }
    }
    ?>
    <form method="post" name="frm">
    <input name="name" type="text">

    <input name="pass" type="password">

    <input name="submit" type="submit" value="submit">
    </form>

    Cosa succede se nel file sono presenti 3 username pippo?

    Il valore assegnato allo user pippo sarà solo quello della terza password e quindi 2 utenti non riusciranno a loggarsi.




    thelinuxbadguys

  4. #14

    ...........

    Devi fare un controllo
    su username non vuoi
    user come O'relly pe
    e poi un'altro sul file
    per vedere se il nome esiste
    Fammi sapere e divertiti
    Per il primo puoi usare questa
    function validUsername($username)
    {
    if(preg_match('/^[a-z0-9\-_]{2,16}$/', $username))
    {
    return true;
    }
    return false;
    }
    per il secondo recuperi name
    lo metti in un array e poi
    fai un controllo di questo
    genere

    if(in_array($postValue,$array))
    Without faith, nothing is possible. With it, nothing is impossible
    http://ilwebdifabio.it

  5. #15
    Ok Funziona!

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.