File tree Expand file tree Collapse file tree 4 files changed +57
-11
lines changed Expand file tree Collapse file tree 4 files changed +57
-11
lines changed Original file line number Diff line number Diff line change @@ -67,3 +67,7 @@ header a{
67
67
}
68
68
69
69
/********************************************************/
70
+
71
+ td {
72
+ border : 1px solid black;
73
+ }
Original file line number Diff line number Diff line change 2
2
include_once ('header.php ' );
3
3
include_once ('footer.php ' );
4
4
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
+ }
5
25
?>
6
26
<h1>Welcome Admin</h1>
7
27
<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>
Original file line number Diff line number Diff line change 8
8
header ("Location:profileN.php " );
9
9
}
10
10
11
- if ( isset ($ _POST ['modify ' ]) ) {
11
+ if (isset ($ _POST ['modify ' ]) ) {
12
12
//un champ obligatoire
13
13
if ( !empty ($ _POST ['firstName ' ]) )
14
14
{
15
+ echo "fn " ;
15
16
$ username = trim ($ _POST ['firstName ' ]) ;
16
17
}
17
18
else
18
19
{
20
+ echo "fn2 " ;
19
21
$ mistakes ['firstName ' ] = true ;
20
22
}
21
23
if ( !empty ($ _POST ['lastName ' ]) )
40
42
$ mistakes ['passmod ' ] = true ;
41
43
}
42
44
43
-
44
-
45
-
46
-
47
- //un champ obligatoire avec certaines valeurs rejetées
48
-
49
-
50
-
51
-
52
45
//s'il n'y a pas d'erreur...
53
46
if (!empty ($ mistakes ))
54
47
{
Original file line number Diff line number Diff line change 23
23
}
24
24
25
25
26
- if ( !empty ($ _POST ['password ' ]) AND isset ($ _POST ['cpassword ' ])){
26
+ if ( !empty ($ _POST ['password ' ]) AND isset ($ _POST ['cpassword ' ]) AND strlen ( $ _POST [ ' password ' ])>= 4 ){
27
27
if ($ _POST ["password " ]== $ _POST ["cpassword " ]) {
28
28
$ password = trim ($ _POST ['password ' ]);
29
29
$ passhash = sha1 ($ password );
You can’t perform that action at this time.
0 commit comments