Buongiorno a tutti,
ho una domanda riguardante un piccolo programmino di gestione che ho fatto per un cliente.
Essendo sempre stato in locale non vi era bisogno di login come admin.
In pratica dovrei fare si che nella prima pagina mi chiede un user e pass, di modo che identifichi l'utente come admin, a quel punto con la sessione attiva potrei fare le pagine dinamiche secondo i permessi utente.
Nel caso non mi loggassi, sarei un utente "base".

Nell'index ho messo questo codice

Codice PHP:
<?php
    $login_form 
= <<<EOD<form name="login" id="login" method="POST" action="check_login.php"><p><label for="username">Please Enter Username: </label><input type="text" size="100" name="username" id="username" value="Enter Username here" /></p><p><label for="password">Please Enter Password: </label><input type="password" size="40" name="password" id="password" value="abracadabra" /></p><p><input type="submit" name="submit" id="submit" value="Submit"/> <input type="reset" name="reset" id="reset" value="reset"/></p></form>EOD;@$msg $_GET['msg'];  //GET the message
if($msg!='') echo '<p>'.$msg.'</p>'//If message is set echo it
echo "<h1>Please enter your Login Information</h1>";
echo 
$login_form;?>
Ho poi creato il file check_login

Codice PHP:
<?phpdefine(DOC_ROOT,dirname(__FILE__)); // To properly get the config.php file
$username $_POST['username']; //Set UserName
$password $_POST['password']; //Set Password
$msg ='';if(isset($username$password)) {    ob_start();    include(DOC_ROOT.'/config.php'); //Initiate the MySQL connection    // To protect MySQL injection (more detail about MySQL injection) 
   
$myusername stripslashes($username);    
$mypassword stripslashes($password);   
 
$myusername mysqli_real_escape_string($dbC$myusername);    
$mypassword mysqli_real_escape_string($dbC$mypassword);    
$sql="SELECT * FROM login_admin WHERE user_name='$myusername' and user_pass=barge1('$mypassword')";    $result=mysqli_query($dbC$sql);    // Mysql_num_row is counting table row    
$count=mysqli_num_rows($result);    // If result matched $myusername and $mypassword, table row must be 1 row  
  
if($count==1){        // Register $myusername, $mypassword and redirect to file "admin.php"
        
session_register("admin");        
session_register("password");        
$_SESSION['name']= $myusername;        header("location:admin.php");    }    else {        $msg "Wrong Username or Password. Please retry";        header("location:index.php?msg=$msg");    }    ob_end_flush();}else {    header("location:index.php?msg=Please enter some username and password");}?>
Infine

Codice PHP:
<?php

$dbHost 
'localhost';$dbUser 'marcello';$dbPass 'barge1';$dbName 'prova';$dbC mysqli_connect($dbHost$dbUser$dbPass$dbName)        or die('Error Connecting to MySQL DataBase');?>
Ricevo però questo messaggio nel check_login:

Warning: mysqli_connect(): (HY000/1045): Access denied for user 'marcello'@'localhost' (using password: YES) in E:\EasyPHP\data\localweb\config.php on line 13
Error Connecting to MySQL DataBase


Logicamente nella tabella è presente lo user marcello con pass barge1.
Posso ricevere qualche dritta oppure sapete un metodo migliore per gestire la cosa?
Grazie in anticipo e un "fresco" agosto a tutti!!