Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
No results found
Show changes
Commits on Source (2)
<?php require_once(__DIR__.'/../static/php/head.php'); ?> <?php
<?php echo htmlspecialchars($_GET['name']).' | Score : '; ?> require_once(__DIR__.'/../config/config.php');
<?php $score = $ddb->query('
$score = $ddb->query('
SELECT score FROM users WHERE name = \''.$_GET['name'].'\' SELECT score FROM users WHERE name = \''.$_GET['name'].'\'
')->fetch(); ')->fetch();
echo $score[0]
echo htmlspecialchars($_GET['name']).' | Score : '.$score[0]
?> ?>
<div>
<h1>My header</h1>
<br>
<p><?php echo "My paragraph" ?></p>
</div>
...@@ -3,4 +3,7 @@ ...@@ -3,4 +3,7 @@
<h1>Page 2</h1> <h1>Page 2</h1>
<?php require_once(APP_ROOT.'/static/php/navbar.php'); ?> <?php require_once(APP_ROOT.'/static/php/navbar.php'); ?>
<h1><?php echo $_SERVER['HTTP_ACCEPT_LANGUAGE'] ?></h1> <h1><?php echo $_SERVER['HTTP_ACCEPT_LANGUAGE'] ?></h1>
<script src="/static/js/ajax.js"></script>
<button onclick="buttonClickAjax()">Click me</button>
<div id="result"></div>
</body> </body>
<?php require_once(__DIR__.'/../static/php/head.php'); ?> <?php require_once(__DIR__.'/../static/php/head.php'); ?>
<body> <body>
<?php require_once(APP_ROOT.'/static/php/navbar.php'); ?> <?php require_once(APP_ROOT.'/static/php/navbar.php'); ?>
<!-- Formulaires classiques -->
<form action="/actions/post.php" method="post"> <form action="/actions/post.php" method="post">
<label for="name"><?php echo $trad['form_name'][$lang]; ?></label> <label for="name"><?php echo $trad['form_name'][$lang]; ?></label>
<input name="name" id="name" type="text"> <input name="name" id="name" type="text">
...@@ -17,4 +18,17 @@ ...@@ -17,4 +18,17 @@
<button type="submit"><?php echo $trad['search'][$lang]; ?></button> <button type="submit"><?php echo $trad['search'][$lang]; ?></button>
</form> </form>
<br>
<!-- Formulaire AJAX -->
<script src="/static/js/ajax.js"></script>
<div>
<form onsubmit="submitFormGetAjax(this)">
<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>
<br>
<label id="result"></label>
</div>
</body> </body>
function submitFormGetAjax(form) {
event.preventDefault();
var request = new XMLHttpRequest();
request.onreadystatechange = function() {
// uniquement en cas de requête envoyée et réussie
if (this.readyState == 4 && this.status == 200)
document.getElementById("result").innerHTML = request.responseText;
};
let name = encodeURIComponent(form.name.value.trim());
request.open("GET", "/actions/get.php?name=" + name, true);
request.send();
}
function buttonClickAjax() {
event.preventDefault();
var request = new XMLHttpRequest();
request.onreadystatechange = function() {
// uniquement en cas de requête envoyée et réussie
if (this.readyState == 4 && this.status == 200)
document.getElementById("result").innerHTML = request.responseText;
};
request.open("GET", "/actions/hello.php", true);
request.send();
}