Current File : /home/d/i/g/digitaw/Ycof/connexion.php
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
    <link href="css/puppop.css" rel="stylesheet">
    <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/popper.js@1.12.9/dist/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
    <title>Document</title>
    <style>
        .password-icon {
            display: flex;
            align-items: center;
            position: absolute;
            top: 64%;
            right: 30px;
            transform: translateY(-50%);
            width: 50px;
            color: #066191;
            transition: all 0.2s;
        }

        .password-icon:hover {
            cursor: pointer;
            color: #B1D8EA;
        }

        .password-icon .feather-eye-off {
            display: none;
        }
        #msg{
            position: fixed;  
            top: 5%;
        }
        @media only screen and (max-width: 600px) {
            #msg{
                position: fixed;
                top:5px;
            }
        }
    </style>

</head>

<body> 

    <?php
    session_start();
    $db_user = "digitawdigitalis";
    
    $db_pass = "N54U55txkP";
    $db_name = "digitawdigitalis";
    $db = new PDO('mysql:host=digitawdigitalis.mysql.db:3306;dbname=' . $db_name . ';charset=utf8', $db_user, $db_pass);
    //  $_SESSION['status'] = "";
    if (isset($_POST['connexion'])) {
        $admin = $_POST['email'];
        $pwd = sha1($_POST['password']);
        $reponse = $db->query("SELECT * FROM utilisateurs WHERE email ='$admin' and passwd='$pwd' ");
        $row = $reponse->fetch();
        $row['email'] ??= '';
        $row['passwd'] ??= '';
        $row['action'] ??= '';
        if ($admin == $row['email'] && $pwd == $row['passwd']) {
            $_SESSION['email'] = $_POST['email'];
            $_SESSION['pwd'] = $_POST['password'];
            if ($row['status'] == 0) {
                if ($row['action']==1) {
                    header('Location: ./client/client.php');
                }else {
                    $msg = "Votre compte a été désactivé. Veuillez contacter l'administrateur";
                }
           
            }else{
                header('Location: ./admin/index.php');
            }
        } else {
            // $_SESSION['status'] = "<div class='alert-danger p-2 text-center'>
            // <b> cet utilisateur est non reconnu ! </b> </div> ";

            $msg = "Username or password incorrect!";
        }
    }
    ?>
<div id="msg">
        <?php if (!empty($msg)) {
                    echo "<div class='alert alert-danger alert-dismissible fade show' role='alert'> 
                                        <p style='font-size:16px;'>$msg</p>
                                    </div>";
                } ?>
        </div>
    <div class="container"> 
        
        <div class="brand-logo"> 
            <a href="index.html" style="background-color: none;margin: 0;padding: 0;">
                <img src="img/ycof_logo.png" width="99px" style="margin-top: 10px;" alt="">
            </a> 
        </div> 
        <div class="brand-title">Connexion</div>
        <div class="inputs">
            <form method="POST" action="" id="form-connexion"> 
                <input type="email" name="email" placeholder="Votre email" required /> <br>
                <input type="password" name="password" placeholder="Mot de passe" required minlength="4" />
                <div class="password-icon">
                    <i data-feather="eye"></i>
                    <i data-feather="eye-off"></i>
                </div>
                <button name="connexion" type="submit">Se connecter</button><br>
                <a href="index.html" style="color:  #066191; text-decoration: none;"> <button type="button" id="accueil">Accueil</button></a> 
            </form>
        </div>
        
    </div>
    <script src="https://unpkg.com/feather-icons"></script>
    <script>
        feather.replace();

        const eye = document.querySelector(".feather-eye");
        const eyeoff = document.querySelector(".feather-eye-off");
        const passwordField = document.querySelector("input[type=password]");

        eye.addEventListener("click", () => {
            eye.style.display = "none";
            eyeoff.style.display = "block";
            passwordField.type = "text";
        });

        eyeoff.addEventListener("click", () => {
            eyeoff.style.display = "none";
            eye.style.display = "block";
            passwordField.type = "password";
        });
    </script>
</body>

</html>