Skip to content

Commit 3fdebdb

Browse files
committed
Not fully working
1 parent 7694c1e commit 3fdebdb

File tree

4 files changed

+57
-11
lines changed

4 files changed

+57
-11
lines changed

Custom/css/styles.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,7 @@ header a{
6767
}
6868

6969
/********************************************************/
70+
71+
td{
72+
border: 1px solid black;
73+
}

admin.php

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,55 @@
22
include_once('header.php');
33
include_once('footer.php');
44
include_once('db.php');
5+
6+
$host = 'localhost';
7+
$dbname = 'samplitek';
8+
$username = 'root';
9+
$password = '';
10+
$dsn = "mysql:host=$host;dbname=$dbname";
11+
// get all users
12+
$sql = "SELECT * FROM Users";
13+
14+
try{
15+
$pdo = new PDO($dsn, $username, $password);
16+
$stmt = $pdo->query($sql);
17+
18+
if($stmt === false){
19+
die("Error");
20+
}
21+
22+
}catch (PDOException $e){
23+
echo $e->getMessage();
24+
}
525
?>
626
<h1>Welcome Admin</h1>
727
<h1>Ready to ban some kids ?</h1>
28+
<h1>Users list</h1>
29+
<table>
30+
<thead>
31+
<tr>
32+
<th>ID</th>
33+
<th>Name</th>
34+
<th>Email</th>
35+
<th>First Name</th>
36+
<th>Last Name</th>
37+
<th>Rights</th>
38+
<th>Not banned yet</th>
39+
</tr>
40+
</thead>
41+
<tbody>
42+
<?php while($row = $stmt->fetch(PDO::FETCH_ASSOC)) : ?>
43+
<tr>
44+
<td><?php echo htmlspecialchars($row['id']); ?></td>
45+
<td><?php echo htmlspecialchars($row['username']); ?></td>
46+
<td><?php echo htmlspecialchars($row['email']); ?></td>
47+
<td><?php echo htmlspecialchars($row['firstName']); ?></td>
48+
<td><?php echo htmlspecialchars($row['lastName']); ?></td>
49+
<td><?php echo htmlspecialchars($row['rights']); ?></td>
50+
<td><?php echo htmlspecialchars($row['active']); ?></td>
51+
</tr>
52+
<?php endwhile; ?>
53+
</tbody>
54+
</table>
55+
56+
<p>To do : Add an easy way to ban kids</p>

profile.php

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,16 @@
88
header("Location:profileN.php");
99
}
1010

11-
if ( isset($_POST['modify']) ) {
11+
if (isset($_POST['modify']) ) {
1212
//un champ obligatoire
1313
if ( !empty($_POST['firstName']) )
1414
{
15+
echo "fn";
1516
$username = trim($_POST['firstName']) ;
1617
}
1718
else
1819
{
20+
echo "fn2";
1921
$mistakes['firstName'] = true;
2022
}
2123
if ( !empty($_POST['lastName']) )
@@ -40,15 +42,6 @@
4042
$mistakes['passmod'] = true;
4143
}
4244

43-
44-
45-
46-
47-
//un champ obligatoire avec certaines valeurs rejetées
48-
49-
50-
51-
5245
//s'il n'y a pas d'erreur...
5346
if (!empty($mistakes))
5447
{

signin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
}
2424

2525

26-
if ( !empty($_POST['password']) AND isset($_POST['cpassword'])){
26+
if ( !empty($_POST['password']) AND isset($_POST['cpassword']) AND strlen($_POST['password'])>=4){
2727
if ($_POST["password"]== $_POST["cpassword"]) {
2828
$password = trim($_POST['password']);
2929
$passhash = sha1($password);

0 commit comments

Comments
 (0)