Skip to content
Snippets Groups Projects
Commit 15d2eed2 authored by Nawreua's avatar Nawreua
Browse files

TP4 : ajout des formulaires GET et POST + interaction BDD

parent 4b81599b
Branches
No related merge requests found
<?php require_once(__DIR__.'/../static/php/head.php'); ?>
<?php echo htmlspecialchars($_GET['name']).' | Score : '; ?>
<?php $score = $ddb->query('
SELECT score FROM users WHERE name = \''.$_GET['name'].'\'
')->fetch();
echo $score[0]
?>
<?php require_once(__DIR__.'/../static/php/head.php'); ?>
<?php echo htmlspecialchars($_POST['name']); ?>, <?php echo $_POST['score']; ?>
<?php $ddb->query('
INSERT INTO users (name, score)
VALUES (\''.$_POST['name'].'\', '.$_POST['score'].')
');
?>
<?php require_once(__DIR__.'/../static/php/head.php'); ?>
<body>
<?php require_once(APP_ROOT.'/static/php/navbar.php'); ?>
<form action="/actions/post.php" method="post">
<label for="name"><?php echo $trad['form_name'][$lang]; ?></label>
<input name="name" id="name" type="text">
<label for="score"><?php echo $trad['form_score'][$lang]; ?></label>
<input name="score" id="score" type="number">
<button type="submit"><?php echo $trad['register'][$lang]; ?></button>
</form>
<br>
<form action="/actions/get.php" method="get">
<label for="name"><?php echo $trad['form_name'][$lang]; ?></label>
<input name="name" id="name" type="text">
<button type="submit"><?php echo $trad['search'][$lang]; ?></button>
</form>
</body>
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
<li><a href="/"><?php echo $trad['home'][$lang] ?></a></li> <li><a href="/"><?php echo $trad['home'][$lang] ?></a></li>
<li><a href="/pages/page1.php">Page 1</a></li> <li><a href="/pages/page1.php">Page 1</a></li>
<li><a href="/pages/page2.php">Page 2</a></li> <li><a href="/pages/page2.php">Page 2</a></li>
<li><a href="/pages/pageForm.php"><?php echo $trad['form'][$lang] ?></a></li>
<li><a href="#"><?php echo $trad['contact'][$lang] ?></a></li> <li><a href="#"><?php echo $trad['contact'][$lang] ?></a></li>
</ul> </ul>
</div> </div>
......
...@@ -7,6 +7,26 @@ $trad = [ ...@@ -7,6 +7,26 @@ $trad = [
'contact' => [ 'contact' => [
'fr' => 'Contactez-nous', 'fr' => 'Contactez-nous',
'en' => 'Contact us' 'en' => 'Contact us'
],
'form' => [
'fr' => 'Formulaires',
'en' => 'Forms'
],
'form_name' => [
'fr' => 'Votre nom :',
'en' => 'Your name:'
],
'form_score' => [
'fr' => 'Votre score :',
'en' => 'Your score:'
],
'register' => [
'fr' => 'Enregistrer',
'en' => 'Submit'
],
'search' => [
'fr' => 'Rechercher',
'en' => 'Search'
] ]
]; ];
?> ?>
......
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