diff --git a/createUser.php b/createUser.php new file mode 100644 index 0000000..42dfa21 --- /dev/null +++ b/createUser.php @@ -0,0 +1,43 @@ +prepare("SELECT * FROM user WHERE username = ?"); + $req->execute(array($username)); + + if ($req->fetch()) { ?> +
Username already exist !
+ closeCursor(); + $req = $bdd->prepare("INSERT INTO user VALUES (?, ?, ?)"); + $req->execute(array($username, $word, $nb)); + $_SESSION["p1905458"] = $username; + header("Location: helloworld4.php"); + } + $req->closeCursor(); + } catch (Exception $e) { + databaseError($e); + } + elseif ($bdd INSTANCEOF Exception) + databaseError($bdd); + } +?> + + + diff --git a/db.php b/db.php new file mode 100644 index 0000000..f67b6de --- /dev/null +++ b/db.php @@ -0,0 +1,15 @@ +setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + return $bdd; + } catch (Exception $e) { + return $e; + } +} diff --git a/footer.php b/footer.php new file mode 100644 index 0000000..b317cc2 --- /dev/null +++ b/footer.php @@ -0,0 +1,2 @@ +