Marijn button #99

Merged
11166932 merged 152 commits from marijn-button into master 2017-01-23 13:25:08 +01:00
2 changed files with 36 additions and 43 deletions
Showing only changes of commit 8ce6cd1aa2 - Show all commits

View File

@@ -1,6 +1,6 @@
<?php
function selectSomeUsers($db, $n) {
function select20UsersFromN($db, $n) {
return $db->query("
SELECT
`userID`,
@@ -10,10 +10,35 @@ function selectSomeUsers($db, $n) {
FROM
`user`
ORDER BY
`role`,
`username`
LIMIT
$n
$n, 20
");
}
function search20UsersFromN($db, $n, $keyword) {
$q = $db->prepare("
SELECT
`userID`,
`username`,
`role`,
`bancomment`
FROM
`user`
WHERE
`username` LIKE :keyword
ORDER BY
`username`
LIMIT
:n, 20
");
$keyword = "%$keyword%";
$q->bindParam(':keyword', $keyword);
$q->bindParam(':n', $n, PDO::PARAM_INT);
$q->execute();
return $q;
}
?>

View File

@@ -20,11 +20,14 @@
<!-- function test_input taken from http://www.w3schools.com/php/php_form_validation.asp -->
<?php
$search = $pagetype = "";
$search = $pagetype = $searchvalue = "";
$listnr = 0;
$status = array();
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$search = test_input($_POST["search"]);
if (!empty($_POST["search"])) {
$search = $searchvalue = test_input($_POST["search"]);
}
if (!empty($_POST["pagetype"])) {
$pagetype = test_input($_POST["pagetype"]);
@@ -112,7 +115,6 @@ function test_input($data) {
<input type="submit" name="next" value="next">
</div> <br>
<table class="usertable">
<tr>
<th class="table-checkbox">
@@ -125,7 +127,8 @@ function test_input($data) {
</tr>
<?php
$q = selectSomeUsers($db, 20);
$q = search20UsersFromN($db, $listnr, $searchvalue);
while($user = $q->fetch(PDO::FETCH_ASSOC)) {
$userID = $user['userID'];
$username = $user['username'];
@@ -158,46 +161,11 @@ function test_input($data) {
");
}
?>
<!-- <tr>
<td><input type="checkbox" name="check1"></td>
<td>John Smith</td>
<td>Banned</td>
<td>unregulated time travel</td>
<td>
<form class="admin-useraction"
action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"
method="post">
<select class="action" name="actions">
<option value="freeze">Freeze</option>
<option value="ban">Ban</option>
<option value="restore">Restore</option>
</select>
<input type="submit" value="Confirm">
</form>
</td>
</tr>
<tr>
<td><input type="checkbox" name="check1"></td>
<td>poey jokeaim</td>
<td>Banned</td>
<td>l33t h4xx</td>
<td>
<form class="admin-useraction"
action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"
method="post">
<select class="action" name="actions">
<option value="freeze">Freeze</option>
<option value="ban">Ban</option>
<option value="restore">Restore</option>
</select>
<input type="submit" value="Confirm">
</form>
</td>
</tr> -->
</table>
</div>
</form>
<pre><?php print_r($_POST); ?></pre>
</div>
</div>
</body>