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 @@ + + \ No newline at end of file diff --git a/header.php b/header.php new file mode 100644 index 0000000..e3b4906 --- /dev/null +++ b/header.php @@ -0,0 +1,20 @@ +getMessage()); + echo "

An error occurred with the database, please contact an administrator

"; + } + + session_name("p1905458"); + session_start(); +?> + + + + + Hello World 4 + + \ No newline at end of file diff --git a/helloworld4.php b/helloworld4.php new file mode 100644 index 0000000..0d3fe33 --- /dev/null +++ b/helloworld4.php @@ -0,0 +1,48 @@ + +
+ + + +
+ + + +