projet-php/index.php

59 lines
1.6 KiB
PHP
Raw Permalink Normal View History

<!DOCTYPE html>
2015-12-02 11:32:57 +00:00
<?php
/*
petite explication : on démarre le systeme de session de php, on inclu notre authentification
, on appelle la fonction que vérifie le login et role de l'utilisateur (voir source pour la doc)
si l'utilisateur est logué, on le redirige vers la page d'accueil de l'outil
*/
session_start();
require('autoloader.php');
if(isset($_POST['co'])){
$Auth = new Authentification();
$Auth->authentification($_POST['username'],$_POST['password']);
}
2015-12-02 11:32:57 +00:00
if(Authentification::checkUser(0)){
header("Location: http://".$_SERVER['HTTP_HOST']."/Dashboard.php");
die();
};
?>
<html>
<head>
<title>Connexion</title>
<meta charset='utf-8'/>
<meta name='description' value='Site de test'/>
<meta name='author' value='{xdrm} & SeekDaSky'/>
2015-12-19 17:15:04 +00:00
<link rel='stylesheet' href='css/font.css'/>
2015-12-13 17:31:08 +00:00
<link rel='stylesheet' href='css/login-material.css'/>
</head>
<body>
2015-12-13 17:31:08 +00:00
<?php
2015-12-13 17:31:08 +00:00
echo "<form action='#auth' method='POST'>";
echo "<input type='text' name='username' id='username' value=''><label for='username'>Username</label>";
echo "<input type='password' name='password' id='password' value=''><label for='password'>Password</label>";
echo "<input type='submit' name='co' value='Me connecter'>";
echo "</form>";
2015-12-02 11:32:57 +00:00
2015-12-13 17:31:08 +00:00
?>
2015-12-13 17:31:08 +00:00
<script type='text/javascript'>
/* On règle le pb d'accessibilité à l'attribut "value" des inputs
* au niveau du CSS
*/
var inputs = document.querySelectorAll('input[type=text], input[type=password]');
for( var i = 0 ; i < inputs.length ; i++ )
inputs[i].addEventListener('change', function(e){ e.target.setAttribute('value', e.target.value); }, false);
</script>
</body>
</html>