Bien au dessus de Léandre et JL
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
925 B

<?php
if (isset($_POST["username"]) && isset($_POST["password"])) {
$bdd = new SQLite3('../users.db', SQLITE3_OPEN_READWRITE);
$request = $bdd->query('SELECT * from users');
while($line = $request->fetchArray()) {
if ($line['username'] == $_POST["username"]) {
echo '<meta http-equiv="refresh" content="0;URL=login.php?error=1">';
exit;
}
}
$append = $bdd->prepare("INSERT INTO users(username, password, compte) VALUES(:username, :password, :compte)");
$append->bindValue(':username', $_POST['username']);
$append->bindValue(':password', sha1($_POST['password']));
$append->bindValue(':compte', 100);
$append->execute();
session_start();
$_SESSION['username'] = $line['username'];
$_SESSION['password'] = $line['password'];
$_SESSION['compte'] = $line['compte'];
echo '<meta http-equiv="refresh" content="0;URL=../jeu/index.php">';
}
?>