Skip to content
Snippets Groups Projects
Commit d358678e authored by BURCKEL Luc's avatar BURCKEL Luc
Browse files

tp3

parent 4aa790df
No related merge requests found
<?php
session_start();
if(isset($_SESSION['login'])){
echo "<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='UTF-8'>
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
<title>Document</title>
</head>
<body>
<footer>
<h1>Bienvenue</h1>
<a href='signout.php'><img src='https://image.flaticon.com/icons/png/512/59/59801.png' width='30' height='30' alt='déconection'></a>
</footer>
</body>
</html>";
}
else{
header("Location: signin.php");
}
?>
\ No newline at end of file
<?php
if($_SERVER['REQUEST_METHOD']!='POST'){header("Location: signup.php");}
$login=htmlentities($_POST['login']);
$mdp=htmlentities($_POST['mdp']);
if(strlen($login)>4){
if($mdp==htmlentities($_POST['mdpConfirmer']) && strlen($mdp)>4){
require('bdd.php');
try {
$pdo = new PDO($SQL_DSN);
}
catch( PDOException $e ) {
echo 'Erreur : '.$e->getMessage();
exit;
}
$request = $pdo->prepare( 'INSERT INTO Users (login, pass) VALUES ( :login , :mdp )');
$request->bindValue( ':login', $login, PDO::PARAM_STR );
$request->bindValue( ':mdp', $mdp, PDO::PARAM_STR );
$request->execute();
}
else{
header("Location: signup.php");
}
}
else{
header("Location: signup.php");
}
?>
\ No newline at end of file
<?php
session_start();
if($_SERVER['REQUEST_METHOD']!='POST'){header("Location: signin.php");}
require('bdd.php');
$pdo=new PDO($SQL_DSN);
$request=$pdo->prepare("Select pass,login from Users where login= :login ;");
$request->bindvalue( ':login', $_POST['login'], PDO::PARAM_STR );
$request->execute();
$row = $request->fetch(PDO::FETCH_ASSOC);
if($_POST['mdp']==$row['pass'] && $_POST['mdp']!=""){
$_SESSION['login']=$_POST['login'];
header("Location: account.php");
}
else{
if($_POST['login']!=$row['login'] || $_POST['login']==""){
$_SESSION['speudo']="";
$message="L'identifient n'existe pas";
}
else{
$_SESSION['speudo']=$_POST['login'];//
$message="Le mot de passe n'est pas bon";
}
$_SESSION['message']=$message;
header("Location: signin.php");
}
?>
\ No newline at end of file
<?php
$sqlFile=__DIR__.'/tp3.db';
echo $sqlFile;
if(!file_exists($sqlFile)){
throw new Exception("Erreur : Pas de fichier db");
}
$SQL_DSN="sqlite:".$sqlFile;
?>
\ No newline at end of file
<?php session_start(); ?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
<link href="style.css" rel="stylesheet">
<title>Document</title>
</head>
<body>
<header>
<form action="authenticate.php" method="POST">
<label>Login : </label><input type="text" name="login" value=<?php if(isset($_SESSION['speudo'])){if($_SESSION['speudo']!=""){echo $_SESSION['speudo'];}} ?>><br>
<label>Mot de passe : </label><input type="password" name="mdp"><br>
<input type="submit" id="button" value="Connextion"><br>
</form>
<a href="signup.php"><p>Inscription</p></a>
</header>
<section>
<?php
if(isset($_SESSION['message'])){
if($_SESSION['message']!=""){
echo $_SESSION['message'];
}
}
?>
</section>
</body>
</html>
\ No newline at end of file
<?php
session_start();
session_destroy();
header("Location: signin.php");
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
<link href="style.css" rel="stylesheet">
<title>Document</title>
</head>
<body>
<header>
<form action="adduser.php" method="POST">
<label>Login : </label><input type="text" name="login" value=<?php if(isset($_SESSION['speudo'])){if($_SESSION['speudo']!=""){echo $_SESSION['speudo'];}} ?>><br>
<label>Mot de passe : </label><input type="password" name="mdp"><br>
<label>Confirmer mot de passe : </label><input type="password" name="mdpConfirmer"><br>
<input type="submit" id="button" value="Inscription"><br>
</form>
<a href="signin.php"><p>Connection</p></a>
</header>
<section>
<?php
if(isset($_SESSION['message'])){
if($_SESSION['message']!=""){
echo $_SESSION['message'];
}
}
?>
</section>
</body>
</html>
\ No newline at end of file
body{
font-size: larger;
text-align: center;
display: flex;
justify-content: center;
flex-direction:column;
align-items: center;
}
header{
padding: 15px;
justify-content: center;
border: 3px solid black;
}
#button{
margin-top: 10px;
border-color: black;
font-weight: bold;
font-size: 105%;
font-family: 'Courier New', Courier, monospace;
background-color: cornflowerblue;
}
section{
color: crimson;
}
\ No newline at end of file
File added
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment