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

Discussione: [PHP] Area Riservata

  1. #1

    [PHP] Area Riservata

    Salve,

    sto creando un'area riservata, per capire meglio ho creato solo 2 pagine una si chiama index.php e laltra index2.php!
    Lo script lo sto creando quindi non é completo.
    Come faccio a far stampare il nome dell'utente che si é loggato nella pagina index2.php?
    Se sbaglio datemi una dritta anche per la pagina index.php!!

    Nella pagina index.php ho fatto:

    <?php

    session_start();

    $_SESSION['UserName'] = $Username;
    $_SESSION['Password'] = $Password;
    $_SESSION['LoginSucces'] = "Admin";

    $Usr = "Admin";
    $Pwd = "1234";
    $Username = $_POST['usr'];
    $Password = $_POST['pwd'];
    $LoginOk = "index2.php";


    if (isset($_POST['Submit'])) {

    if($Username==$Usr || $Password==$Pwd) {
    header("Location: $LoginOk");
    exit();
    } else {
    $msg = "Errore, controllare il nome utente e la password \n"
    }
    }
    ?>
    <head>
    </head>
    <body>
    <table width="450" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
    <td><form name="form1" method="post" action="">
    <table width="450" border="1" cellspacing="0" cellpadding="0">
    <tr>
    <td colspan="2"><div align="center">Area Login: </div></td>
    </tr>
    <tr>
    <td colspan="2"><div align="center"><?php echo $msg;?> </div> </td>
    </tr>
    <tr>
    <td width="225">Username :</td>
    <td width="225"><input name="usr" type="text" id="usr"></td>
    </tr>
    <tr>
    <td>Password : </td>
    <td><input name="pwd" type="password" id="pwd"></td>
    </tr>
    <tr>
    <td></td>
    <td><input type="submit" name="Submit" value="Login"></td>
    </tr>
    </table>
    </form>
    </td>
    </tr>
    </table>


    </body>
    </html>

    Nella pagina index2.php ho messo:

    <?php

    session_start();

    ?>
    <head>
    </head>
    <body>
    Benvenuto:<?php echo $_SESSION['UserName'] ;?>
    </body>
    </html>


    Grazie
    Michel
    PHP THE BEST

  2. #2
    Up
    PHP THE BEST

  3. #3
    nessuno mi sa dare una mano ragazzi??

    Thx

    Michel
    PHP THE BEST

  4. #4
    codice:
    <?php
    echo "ciao ".$_SESSION['user'];
    ?>

  5. #5
    <?php

    session_start();
    $Usr = "Admin";
    $Pwd = "1234";
    $Username = $_POST['usr'];
    $Password = $_POST['pwd'];
    $LoginOk = "index2.php";
    $_SESSION['UserName'] = $Username;
    $_SESSION['Password'] = $Password;
    $_SESSION['LoginSucces'] = "Admin";
    sennò $_SESSION['UserName'] e ['Password'] non vengono valorizzati.....credo....

  6. #6
    Ok spostado il tutto come mi hai detto ora mi da il messaggio giusto (ciao Admin)!!

    Ora ho notato che quando faccio il login se metto una qualsiasi password va ugualmente alla pagina index2.php, mi sapreste dire dove sbaglio pf!!!

    <?php

    session_start();

    $Usr = "Admin";
    $Pwd = "1234";
    $Username = $_POST['usr'];
    $Password = $_POST['pwd'];
    $LoginOk = "index2.php";
    $_SESSION['UserName'] = $Username;
    $_SESSION['Password'] = $Password;

    if (isset($_POST['Submit'])) {

    if($Username==$Usr || $Password==$Pwd) {
    header("Location: $LoginOk");
    exit();
    } else {
    $msg = "<span class=\"style1\">Errore, controllare il nome utente e la password \n</span>";
    }
    }
    ?>
    PHP THE BEST

  7. #7
    è sbagliato questo
    if($Username==$Usr || $Password==$Pwd) {
    i || sono uguali all'operatore logico or
    quello giusto è &&

  8. #8
    Grazie per la dritta!!!
    PHP THE BEST

  9. #9
    Ho un'altra domanda sul fatto della sicurezza!!

    Sicuramente ho qualche problema nel fatto di sicurezza, qualcuno mi sa dare dei consigli??

    Codice:

    <?php

    session_start();

    if ($_SESSION['UserName']==""&&($_SESSION['Password']=="")){
    header("Location: index.php");
    }

    ?>
    <head>
    </head>
    <body>
    <?php
    echo "ciao ".$_SESSION['UserName'];
    ?>
    </body>
    </html>

    Grazie!

    Michel
    PHP THE BEST

  10. #10
    Se per la sicurezza intendi la password, usa l' md5($variabile_da_criptare);
    però,anche se di meno, ormai nn è sicuro manco questo

    Ciao

    Alberto

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.