PHP Classes

File: ajaxusers.php

Recommend this page to a friend!
  Classes of zinsou A.A.E.Moïse   tinyUGatMs   ajaxusers.php   Download  
File: ajaxusers.php
Role: Auxiliary script
Content type: text/plain
Description: php script for ajax user properties load
Class: tinyUGatMs
Manage users and groups of events in a database
Author: By
Last change:
Date: 6 years ago
Size: 4,983 bytes
 

Contents

Class file image Download
<?php
    session_start
();
    require_once(
'config.php');
   
$url="./manageusers.php";
   
// if (empty($_POST['group']))
   
if (empty($_GET['user']))
   
//Oublie d'un champ
   
{
        echo
'<script type="text/javascript">window.location="'.$url.'";</script>';
    }
    else
   
//On check le mot de passe
       
{
        if(!isset(
$_GET["delete"])){
           
$query=$bdd->prepare('SELECT * FROM users WHERE username=:name');
           
$query->bindValue(':name',$_GET['user'],PDO::PARAM_STR);
           
$query->execute();
           
$data=$query->fetch();
           
$query->CloseCursor();
           
?>
<!--<form id="properties" method="POST">-->
            <fieldset>
            <legend>Properties</legend>
            <p>
            <label for="oldusername">oldusername</label><input name="oldusername" type="text" id="oldusername" value="<?php echo $data['username'];?>" disabled="disabled"/><br>
            <label for="name">username</label><input name="username" type="text" id="username" value="<?php echo $data['username'];?>"/><br>
            <label for="password">password:</label><input type="password" name="password" id="password" value="<?php echo $data['password'];?>"/><br>
            <label for="firstname">firstname</label><input name="firstname" type="text" id="firstname" value="<?php echo $data['firstname'];?>"/><br>
            <label for="lastname">lastname</label><input name="lastname" type="text" id="lastname" value="<?php echo $data['lastname'];?>"/><br>
            <label for="email">email</label><input name="email" type="text" id="email" value="<?php echo $data['mail'];?>" /><br>
            <label for="groupid">group</label><select name="groupid" id="groupid">
            <?php

            $query
=$bdd->query('SELECT idgroup,name FROM groups');

           
$query->execute();

            while(
$data2=$query->fetch()){
                if(
$data2["idgroup"]==$data["groupid"]){
                    echo
'<option value='.$data2["idgroup"].' id='.$data2["name"].' selected="selected">'.$data2["name"].'</option>';
                }else{
                    echo
'<option value='.$data2["idgroup"].' id='.$data2["name"].'>'.$data2["name"].'</option>';
                }
            }
           
?></select><br>
            <?php
                $role
= array
                (
'user','admin','modo');
                echo
'<label for="role">role</label>';
                echo
'<select name="role" id="role">';
                for(
$i=0;$i<3;$i++)
                {
                    if (
$role[$i] == $data['role'])
                        {
                        echo
'<option value="'.$data['role'].'" selected="selected">'.$data['role'].'</option>';
                    }
                    else
                    {
                        echo
'<option value="'.$role[$i].'">'.$role[$i].'</option>';
                    }
                }
                echo
'</select><br>';
               
$statut = array
                        (
'pending','activate');
                        echo
'<label for="statut">statut</label>';
                        echo
'<select name="statut" id="statut">';
                        for(
$i=0;$i<2;$i++)
                        {
                            if (
$i==$data["statutvalidation"])
                            {
                                echo
'<option value="'.$i.'" selected="selected">'.$statut[$data['statutvalidation']].'</option>';
                            }
                            else
                            {
                                echo
'<option value="'.$i.'">'.$statut[$i].'</option>';
                            }
                        }
                echo
'</select><br>';
       
?>

           
            </fieldset>
            <p><input type="submit" value="Submit" /></p>
            <!--</form><div id="manage2"></div>-->
            <?php
            $query
->CloseCursor();
        }else{

           
$query=$bdd->prepare('SELECT * FROM users WHERE username=:name');
           
$query->bindValue(':name',$_GET['user'],PDO::PARAM_STR);
           
$query->execute();
           
$data=$query->fetch();
           
$query->CloseCursor();
           
?>
<!--<form id="properties" method="POST">-->

            <legend>Properties</legend>
            <p>
            <label for="oldusername">oldusername</label><input name="oldusername" type="text" id="oldusername" value="<?php echo $data['username'];?>" disabled="disabled"/><br>
            <label for="username">username</label><input name="username" type="text" id="username" value="<?php echo $data['username'];?>" disabled="disabled"/><br>
            <label for="password">password:</label><input type="password" name="password" id="password" value="<?php echo $data['password'];?>" disabled="disabled"/><br>
            <label for="firstname">firstname</label><input name="firstname" type="text" id="firstname" value="<?php echo $data['firstname'];?>" disabled="disabled"/><br>
            <label for="lastname">lastname</label><input name="lastname" type="text" id="lastname" value="<?php echo $data['lastname'];?>" disabled="disabled"/><br>
            <label for="email">email</label><input name="email" type="text" id="email" value="<?php echo $data['mail'];?>" disabled="disabled"/><br>
            <label for="groupid">group's id</label><input name="groupid" type="text" id="groupid" value="<?php echo $data['groupid'];?>" disabled="disabled"/><br>
            <label for="role">role</label><input name="role" type="text" id="role" value="<?php echo $data['role'];?>" disabled="disabled" /><br>
            <label for="role">statut</label><input name="statut" type="text" id="statut" value="<?php echo $data['statutvalidation'];?>" disabled="disabled"/><br></p></p>

            <p><input type="submit" value="Submit" /></p>
            <!--</form><div id="manage2"></div>-->
            <?php
            $query
->CloseCursor();
        }
    }
   
?>