function getUserByName($name) { $db = connectDB(); $sql = 'SELECT * FROM mif22_user WHERE username_user = "******"'; $req = mysql_query($sql) or die('Erreur SQL ! : ' . mysql_error()); $user = new User(); while ($data = mysql_fetch_assoc($req)) { $user->setId($data['id_user']); $user->setUsername($data['username_user']); $user->setPass($data['pass_user']); $user->setType($data['type_user']); } $user->setLevel(getLevelByUser($user)); mysql_close($db); return $user; }
<?php session_start(); require_once '../../db/database.php'; spl_autoload_register('loadClass'); //if(!isset($_SESSION['user']) || $_SESSION['username'] != "-error-") header('Location: accueil.php'); $user = unserialize($_SESSION['user']); $level = getLevelByUser($user); ?> <!DOCTYPE html> <!--[if IE]><![endif]--> <!--[if IE 7 ]> <html lang="fr" class="ie7"> <![endif]--> <!--[if IE 8 ]> <html lang="fr" class="ie8"> <![endif]--> <!--[if IE 9 ]> <html lang="fr" class="ie9"> <![endif]--> <!--[if (gt IE 9)|!(IE)]><!--><html lang="fr"><!--<![endif]--> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="format-detection" content="telephone=no"> <meta name="viewport" content="width=device-width, user-scalable=no, maximum-scale=1.0"> <meta name="description" content="Piano Keyboard developed with HTML, CSS and Javascript"> <meta name="keywords" content="piano, css, html, javascript, front-end"> <title>Piano Keyboard</title> <link type="text/css" rel="stylesheet" href="assets/css/style.css" /> </head> <body>
<a href="../Exercices/Piano/indexEnseignant.php"><button class="btn btn-danger">Créer un exercice de Piano</button></a> </td> </tr> </table> </header> <h1>Panel de l'enseignant <?php echo $_SESSION['username']; ?> </h1> <h2> Les étudiants</h2> <?php foreach ($students as $student) { $level = getLevelByUser($student); echo '<h3>' . $student->getUsername() . '</h3>'; ?> <h4>Exercices instruments - Niveau <?php echo $level['Instruments']; ?> </h4> <h4>Exercices portée</h4> <ul> <li>Exercice 1 Sol : <?php echo $level['Portee']['Ex1Sol']; ?> </li> <li>Exercice 2 Sol : <?php