Ciao probabilmente è una banalità ma non mi riesce applicare questo semplice controllo senza database ne nulla
html
<?php
require('login.php');
?>
<header class="header">
<div class="branding">
<div class="container">
<!-- repo per img : assets -->
<nav class="navbar col-sm-10">
<h1 class="site-logo"><a class="navbar-brand" href="/">
<img class="logo-icon" src="../assets/images/logo.png" alt="logo">
<span class="logo-text">Trovami.com </span></a></h1>
<form action="login.php" method="post">
Login: <br /> <input type="text" name="name" /> <br />
Haslo: <br /> <input type="password" name="password" /> <br /><br />
<input type="submit" value="login" />
</form>
<!--//social-list-->
<ul class="social-list list-inline mt-4">
<li class="list-inline-item"><a class="text-dark" href="#">
<i class="fab fa-twitter fa-fw"></i></a></li>
<li class="list-inline-item"><a class="text-dark" href="#">
<i class="fab fa-facebook-f fa-fw"></i></a></li>
<li class="list-inline-item"><a class="text-dark" href="#">
<i class="fab fa-instagram fa-fw"></i></a></li>
</ul>
</nav>
</div><!--//container-->
</div><!--//branding-->
</header><!--//header-->
php
<?php
if(isset($_POST['password'])){
$login = $_POST['name'];
$password = $_POST['password'];
function ft_checkLenght($password){
if (strlen($password) >= 8){
return false;
}else{
return true;
}
}
function ft_checkCapital($password)
{
for ($i = 0; $i< strlen($password); $i++) {
if(ctype_upper($password[$i])) {
return true;
break;
}else{
return false;
}
}
}
function ft_checkDigit($password)
{
for ($i = 0; $i< strlen($password); $i++) {
if(ctype_digit($password[$i])) {
return true;
break;
}else{
return false;
}
}
}
function checkPassword($password){
if (ft_checkLenght($password) != 0 && ft_checkDigit($password) != 0 && ft_checkCapital($password) != 0)
{
echo 'accesso eseguito correttamente!';
}else{
echo 'accesso fallito, controllare le credenziali!';
}
}
checkPassword($password);
}
?>