49 lines
1.8 KiB
PHP
49 lines
1.8 KiB
PHP
|
<?php
|
||
|
$username = "";
|
||
|
if (isset($_POST["username"]))
|
||
|
$username = htmlspecialchars($_POST["username"]);
|
||
|
elseif ($_SESSION["p1905458"]) {
|
||
|
$username = $_SESSION["p1905458"];
|
||
|
if ( ini_get ( " session . use_cookies " ) ) {
|
||
|
$params = session_get_cookie_params();
|
||
|
setcookie(session_name(), "", -1, $params["path"], $params["domain"], $params["secure"], $params["httponly"]);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
require("header.php");
|
||
|
?>
|
||
|
<form method="POST">
|
||
|
<label for="username">Username: </label>
|
||
|
<input id="username" name="username" value="<?= $username ?>" required>
|
||
|
<input type="submit">
|
||
|
</form>
|
||
|
|
||
|
<ul>
|
||
|
<?php
|
||
|
if ($username) {
|
||
|
$bdd = getPDO();
|
||
|
if ($bdd INSTANCEOF PDO)
|
||
|
try {
|
||
|
$req = $bdd->prepare("SELECT * FROM user WHERE username = ?");
|
||
|
$req->execute(array($username));
|
||
|
|
||
|
if (!$user = $req->fetch()) { ?>
|
||
|
<p><strong>No user found !</strong></p>
|
||
|
<a href="createUser.php"><button>Create a new user</button></a>
|
||
|
<?php } else {
|
||
|
for ($i = 0; $i < $user["nb"]; $i++) { ?>
|
||
|
<li>Hello <?= $user["word"] ?> !</li>
|
||
|
<?php }
|
||
|
}
|
||
|
$req->closeCursor();
|
||
|
} catch (Exception $e) {
|
||
|
databaseError($e);
|
||
|
}
|
||
|
elseif ($bdd INSTANCEOF Exception)
|
||
|
databaseError($bdd);
|
||
|
}
|
||
|
?>
|
||
|
</ul>
|
||
|
|
||
|
<?php require("footer.php") ?>
|