locomputing
users.php Teil 1 
User auflisten
<?php
if (isset($_SESSION['id']) && $_SESSION['id']==1)
{
if ($jumpi=='users')
{
echo'<table class="table">';
echo'<tr><th colspan="5">User Edit</th></tr>';
echo'<tr class="big">';
echo'<td>ID</td>';
echo'<td>Username</td>';
echo'<td>Gesperrt?</td>';
echo'<td>Aktiviert?</td>';
echo'<td>Delete</td>';
echo'</tr>';
echo'<tr>';
echo'<td>1</td>';
echo'<td>Admin</td>';
echo'<td>Nie</td>';
echo'<td>Immer</td>';
echo'<td>Nie</td>';
echo'</tr>';
$aid=1;
$stmt=$pdo->prepare("SELECT id,username,usermail,active,block FROM usertable WHERE NOT id=:aid");
$stmt->bindParam(':aid',$aid,PDO::PARAM_INT);
$stmt->bindColumn(1,$user_id);
$stmt->bindColumn(2,$user_name);
$stmt->bindColumn(3,$user_mail);
$stmt->bindColumn(4,$aktiv);
$stmt->bindColumn(5,$blok);
$stmt->execute();
while ($stmt->fetch())
{
if($blok==0)$blockout='Nein';
if($blok==1)$blockout='Ja';
if($aktiv==0)$activout='Nein';
if($aktiv==1)$activout='Ja';
echo'<tr>';
echo'<td>'.$user_id.'</td>';
echo'<td>';
echo'<a href="index.php?page=99&jump=1&jumpi=uedit&user_id='.$user_id.'">'.$user_name.'</a>';
echo'</td>';
echo'<td>'.$blockout.'</td>';
echo'<td>'.$activout.'</td>';
echo'<td>';
echo'<a href="index.php?page=99&jump=1&jumpi=delprof&user_id='.$user_id.'&user_name='.$user_name.'">✘</a>';
echo'</td>';
echo'</tr>';
}
echo'</table>';
}
?>
= &#10008;
users.php Teil 2 
User editieren
<?php
if ($jumpi=='uedit')
{
if (isset($_POST['save']) && $_POST['save'] == 'Senden')
{
$bloke=isset($_POST['blocken']) ? $_POST['blocken'] : '';
$aktiwe=isset($_POST['actiw']) ? $_POST['actiw'] : '';
$stmt=$pdo->prepare("UPDATE usertable SET block=:blok,active=:aktiv WHERE id=:id");
$stmt->bindParam(':id',$user_id,PDO::PARAM_INT);
$stmt->bindParam(':blok',$bloke,PDO::PARAM_INT);
$stmt->bindParam(':aktiv',$aktiwe,PDO::PARAM_INT);
if ($stmt->execute())
{
header("Location:index.php?page=99&jump=1&jumpi=users");
}
else
{
echo"Da ist was schief gelaufen.";
}
}

$stmt=$pdo->prepare("SELECT id,username,usermail,datum, active, block FROM usertable WHERE id=:id");
$stmt->bindParam(':id',$user_id,PDO::PARAM_INT);
$stmt->bindColumn(1,$user_id);
$stmt->bindColumn(2,$user_name);
$stmt->bindColumn(3,$user_mail);
$stmt->bindColumn(4,$regtime);
$stmt->bindColumn(5,$aktiv);
$stmt->bindColumn(6,$blok);
$stmt->execute();
$stmt->fetch();
$datum=new DateTime($regtime);
if($blok==0)$blogg='<option value="0" selected="selected">Nein</option> <option value="1">Ja</option>';
if($blok==1)$blogg='<option value="1" selected="selected">Ja</option> <option value="0">Nein</option>';
if($aktiv==0)$active='<option value="0" selected="selected">Nein</option> <option value="1">Ja</option>';
if($aktiv==1)$active='<option value="1" selected="selected">Ja</option> <option value="0">Nein</option>';
echo'<form method="post">';
echo'<table class="tables">';
echo'<tr>';
echo'<th colspan="5">User '.$user_name.' editieren</th>';
echo'</tr>';
echo'<tr>';
echo'<td>User-ID:</td>';
echo'<td>'.$user_id.'</td>';
echo'</tr>';
echo'<tr>';
echo'<td>Username:</td>';
echo'<td>'.$user_name.'</td>';
echo'</tr>';
echo'<tr>';
echo'<td>eMail:</td>';
echo'<td>'.$user_mail.'</td>';
echo'</tr>';
echo'<tr>';
echo'<td>Gesperrt?</td>';
echo'<td><select name="blocken"[>'.$blogg.'</select></td>';
echo'</tr>';
echo'<tr>';
echo'<td>Aktiv</td>';
echo'<td>';
echo'<select name="actiw">'.$active.'</select>';
echo'</td>';
echo'</tr>';
echo'<tr>';
echo'<td>Dabei seit: </td>';
echo'<td>'.$datum->format('d.m.Y - H:i:s').'</td>';
echo'</tr>';
echo'<tr>';
echo'<td>';
echo'<input type="submit" class="butli" name="save" value="Senden">';
echo'</td>';
echo'<td>';
echo'<button class="butli" type="submit" formaction="index.php?page=99&jump=1&jumpi=users">zurück</button>';
echo'</td>';
echo'</tr>';
echo'</table>';
echo'</form>';
}
?>
users.php Teil 3 
User löschen
<?php
if ($jumpi=='delprof')
{
$stmt=$pdo->prepare("SELECT id,username FROM usertable WHERE id=:id");
$stmt->bindParam(':id',$user_id,PDO::PARAM_INT);
$stmt->bindColumn(1,$user_id);
$stmt->bindColumn(2,$user_name);
$stmt->execute();
$stmt->fetch();
echo'User = <b>'.$user_name.'</b> wirklich löschen? ';
echo'<a href="index.php?page=99&jump=1&jumpi=delete&user_id='.$user_id.'">Ja</a> | '; echo'<a href="index.php?page=99&jump=1&jumpi=users">Nein</a>';
}

if ($jumpi=='delete')
{
$stmt=$pdo->prepare("DELETE FROM usertable WHERE id=:id");
$stmt->bindParam(':id',$user_id,PDO::PARAM_INT);
if ($stmt->execute())
{
header("Location:index.php?page=99&jump=1&jumpi=users");
}
else
{
echo"Da ist was schief gelaufen";
}
}
}
else
{
header("Location: index.php?page=1");
exit();
}
?>