Oppure

Loading
29/06/21 15:11
alex1995
salve, ho fatto un piccolo cms e sto facendo il login per il pannello admin il mio sorgente che inserisco nelle pagine protette è questo:

<?php

require_once('config.php');
require_once('profile.php');

session_start();

if(isset($_SESSION['username']) && ($_SESSION['password']))
{
	if(!empty($_SESSION['username']) && !empty($_SESSION['password']))
	{
		if($_SESSION['username'] != USER && $_SESSION['password'] != PASSWORD)
		{
			die();
		} 
	}
}

?>


invece quello del form di login è questo:

<?php

print'<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <title></title>
  </head>
  <body>
  <form method="POST" action="login.php">
    <table style="width: 100%" border="1">
      <tbody>
        <tr>
          <td>Username</td>
          <td><input type="text" name="username"></td>
        </tr>
        <tr>
          <td>Password</td>
          <td><input type="password" name="password"></td>
        </tr>
      </tbody>
    </table>
    </form>
    <input type="submit" value="Login" name="Login">
    <p><br>
    </p>
  </body>
</html>
';

if(isset($_POST['username']) && $_POST['password'])
{
	if(!empty($_POST['username']) && !empty($_POST['password']))
	{
		$password = $_POST['password'];
    	$iterations = 2000;
    	$hashalgo = 'sha256';
   		$lenght = 10;

		$hash = hash_pbkdf2($hashalgo, $password, SALT, $iterations, $lenght);

		if($_POST['username'] != USER && $_POST['password'] != PASSWORD)
		{
			die();
		}
		else
		{
			session_start();
			$_SESSION['username'] =$_POST['username'];
			$_SESSION['password'] = $hash;
		}
	}
}

?>



praticamente mi fa entrare anche se scrivo la password sbagliata o vado nella pagina di amministrazione
ps:non fate caso alle xss xD
Ultima modifica effettuata da alex1995 29/06/21 15:13
aaa
29/06/21 15:27
Thejuster
Non so te,
Ma il pulsante submit e fuori dal Form. potrebbe essere quello il problema.
Ultima modifica effettuata da Thejuster 29/06/21 15:38
mire.forumfree.it/ - Mire Engine
C# UI Designer
30/06/21 9:53
alex1995
grazie
ma il problema è che non funziona il primo codice quello che inserisco nei file del pannello admin, o loggato o non loggato mi fa entrare
Ultima modifica effettuata da alex1995 30/06/21 10:07
aaa