Beispiel #1
0
switch ($action) {
    case 'modifier':
        if (!empty($_GET["id"])) {
            // récupperation de l'id dans l'url
            $user_id = $_GET["id"];
            $out = user_update($user_id, $db_connexion);
        }
        // fonction modification ajout de nouvelles données sur le profil
        break;
    case 'image':
        // fonction d'upload d'image
        if (!empty($_GET["id"])) {
            // récupperation de l'id dans l'url
            $user_id = $_GET["id"];
            $action = "?action=image&id={$user_id}";
            $out = user_image_upload($user_id, $db_connexion, $action, true);
        }
        break;
    default:
        // Récupperation de profil de l'utiisateur en cours
        try {
            $stmt = $db_connexion->prepare("SELECT * FROM users where id_user=:user");
            $stmt->bindparam(":user", $user_id);
            $stmt->execute();
            $user = $stmt->fetch();
        } catch (PDOException $e) {
            echo $e->getMessage();
        }
        $out = '';
        $out .= !empty($user["user_pic"]) ? "<img src='upload/300x400_" . $user["user_pic"] . "' >" : "";
        $out .= "Votre pseudo : " . $user["user_name"] . "<br/>";
Beispiel #2
0
function listingUsers($db_connexion, $action = '')
{
    $query = "SELECT * FROM `users` order by `id_user` ASC";
    $statment = $db_connexion->query($query);
    $resultats = $statment->fetchall();
    if (empty($action)) {
        $output = "";
        $entete = array("Pseudo", "Email", "Nom", "Prénom", "Adresse", "Code Postal", "Date de création", "Date de dernière modif", "Actions");
        $output .= "<table class='table table-striped table-hover table-bordered'>\r\n        <thead>\r\n        <tr>";
        // boucle foreach pour créer des TH pour chaque valeur du tableau $entete
        foreach ($entete as $key => $value) {
            $output .= "<th>{$value}</th>";
        }
        $output .= "</tr></thead><tbody>";
        foreach ($resultats as $resultat) {
            $output .= "<tr>";
            $output .= "<td>" . $resultat["user_name"] . "</td>";
            $output .= "<td>" . $resultat["user_email"] . "</td>";
            $output .= "<td>" . $resultat["user_firstname"] . "</td>";
            $output .= "<td>" . $resultat["user_lastname"] . "</td>";
            $output .= "<td>" . $resultat["user_adress"] . "</td>";
            $output .= "<td>" . $resultat["user_zipcode"] . "</td>";
            $output .= "<td>" . $resultat["last_login"] . "</td>";
            $output .= "<td>" . $resultat["date_created"] . "</td>";
            $output .= "<td>\r\n                <ul>\r\n                  <li><a href='utilisateur.php?action=voir&id=" . $resultat["id_user"] . "'>Voir</a></li>\r\n                  <li><a href='utilisateur.php?action=modifier&id=" . $resultat["id_user"] . "'>Modifier</a></li>\r\n                  <li><a href='utilisateur.php?action=supprimer&id=" . $resultat["id_user"] . "'>Supprimer</a></li>\r\n                  </ul>\r\n              </td>\r\n              </tr>";
        }
        $output .= "</tbody>\r\n                </table>";
    } else {
        $action = $_GET['action'];
        if (isset($_GET["id"])) {
            $userID = $_GET["id"];
            switch ($action) {
                case 'voir':
                    $output = "";
                    $user = user_edit($db_connexion, $userID);
                    $output .= file_exists("../upload/300x400_" . $user["user_pic"]) ? "<img src='../upload/300x400_" . $user["user_pic"] . "'><br/>" : "";
                    $output .= !empty($user["user_lastname"]) ? "Nom : " . $user["user_lastname"] . "<br/>" : "";
                    $output .= !empty($user["user_firstname"]) ? "Prénom : " . $user["user_firstname"] . "<br/>" : "";
                    $output .= "Pseudo : " . $user["user_name"] . "<br/>";
                    $output .= "Email : " . $user["user_email"] . "<br/>";
                    break;
                case 'supprimer':
                    try {
                        $statement = $db_connexion->prepare("DELETE FROM users WHERE id_user=:id");
                        $statement->execute(array(":id" => $userID));
                        header("Location:utilisateur.php");
                    } catch (PDOException $e) {
                        echo $e->getMessage();
                    }
                    break;
                case 'modifier':
                    $output = user_update($userID, $db_connexion);
                    $action = "?action=modifier&id=1&step=image";
                    $output .= user_image_upload($userID, $db_connexion, $action, false);
                    break;
            }
        }
    }
    return $output;
}
Beispiel #3
0
    header("Location:index.php");
}
// récupperation de l'identifiant de la session
$user_id = $_SESSION["user_session"];
$action = isset($_GET["action"]) ? $_GET["action"] : "";
switch ($action) {
    case 'modifier':
        if (!empty($_GET["id"])) {
            $out = user_update($user_id, $db_connexion);
        }
        // fonction modification ajout de nouvelles données sur le profil
        break;
    case 'image':
        // fonction d'upload d'image
        if (!empty($_GET["id"])) {
            user_image_upload($user_id, $db_connexion);
            $out = '';
        }
        break;
    default:
        // Récupperation de profil de l'utiisateur en cours
        try {
            $stmt = $db_connexion->prepare("SELECT * FROM users where id_user=:user");
            $stmt->bindparam(":user", $user_id);
            $stmt->execute();
            $user = $stmt->fetch();
        } catch (PDOException $e) {
            echo $e->getMessage();
        }
        $out = '';
        $out .= "Votre pseudo : " . $user["user_name"] . "<br/>";