locomputing
hmenu.php Teil 1 
Menü auflisten
<?php
if (isset($_SESSION['id']) && $_SESSION['id']==1)
{
if($jumpi=='show')
{
echo'<table class="table">';
echo'<tr>'; echo'<th colspan="4">Haupt-Menue</th>';
echo'<th colspan="3">';
echo'<a href="index.php?page=99&jump=2&jumpi=new&jumps=neu">Menüpunkt erstellen</a>';
echo'</th>';
echo'</tr>';
echo'<tr class="big">';
echo'<td>ID</td>';
echo'<td>Menüname</td>';
echo'<td>wohin</td>';
echo'<td>Ziel</td>';
echo'<td>paarID</td>';
echo'<td>Edit</td>';
echo'<td>Del</td>';
echo'</tr>';
$stmt = $pdo->prepare("SELECT id, label, ziel, link_url, parent_id FROM test_menu ORDER BY id");
$stmt->bindColumn(1,$mem_id);
$stmt->bindColumn(2,$m_label);
$stmt->bindColumn(3,$m_ziel);
$stmt->bindColumn(4,$m_link);
$stmt->bindColumn(5,$m_parid);
$stmt->execute();
while($stmt->fetch())
{
echo'<tr>';
echo'<td>'.$mem_id.'</td>';
echo'<td>'.$m_label.'</td>';
echo'<td>'.$m_ziel.'</td>';
echo'<td>'.$m_link.'</td>';
echo'<td>'.$m_parid.'</td>';
echo'<td>';
echo'<a href="index.php?page=99&jump=2&jumpi=recht&mem_id='.$mem_id.'"></a>';
echo'</td>';
echo'<td>';
echo'<a href="index.php?page=99&jump=2&jumpi=del&mem_id='.$mem_id.'">✘</a>';
echo'</td>';
echo'</tr>';
}
echo'</table>';
}
?>
= &#9997; und = &#10008;
hmenu.php Teil 2 
Menüpunkt erstellen
<?php
if($jumpi=='new')
{
echo'<table class="table">';
echo'<tr>';
echo'<th colspan="7">Haupt-Menü</th>';
echo'</tr>';
echo'<tr class="big">';
echo'<td>ID</td>';
echo'<td>Menüname</td>';
echo'<td>Wohin</td>';
echo'<td>Ziel</td>';
echo'<td>paarID</td>';
echo'</tr>';
$stmt = $pdo->prepare("SELECT id,label,ziel,link_url,parent_id FROM test_menu ORDER BY id");
$stmt->bindColumn(1,$mem_id);
$stmt->bindColumn(2,$m_label);
$stmt->bindColumn(3,$m_ziel);
$stmt->bindColumn(4,$m_link);
$stmt->bindColumn(5,$m_parid);
$stmt->execute();
while($stmt->fetch())
{
echo'<tr>';
echo'<td>'.$mem_id.'</td>';
echo'<td>'.$m_label.'</td>';
echo'<td>'.$m_ziel.'</td>';
echo'<td>'.$m_link.'</td>';
echo'<td>'.$m_parid.'</td>';
echo'</tr>';
}
echo'</table>';
if($jumps=='neu')
{
echo'<div class="bigg">Menüpunkt erstellen</div>';
echo'<form action="index.php?page=99&jump=2&jumpi=write&jumps=schreib" method="post">';
echo'<input name="jumps" type="hidden" value="schreib">';
echo'<div class="form-face">';
echo'<input required="required" placeholder=" ID:" class="form-control" name="id" type="text">';
echo'</div>';
echo'<div class="form-face">';
echo'<input required="required" placeholder=" Menüname:" class="form-control" name="label" type="text">';
echo'</div>';
echo'<div class="form-face">';
echo'<input required="required" placeholder=" Wohin:" class="form-control" name="ziel" type="text">';
echo'</div>';
echo'<div class="form-face">';
echo'<input required="required" placeholder=" Ziel:" class="form-control" name="linkurl" type="text">';
echo'</div>';
echo'<div class="form-face">';
echo'<input required="required" placeholder=" PaarID:" class="form-control" name="parentid" type="text">';
echo'</div>';
echo'<div class="form-face">';
echo'<input type="submit" name="schreib" value="Menüpunkt erstellen" class="butt button-blue">';
echo'<input type="reset" value="Löschen" class="butt button-red">';
echo'</div>';
echo'</form>';
}
}
?>
hmenu.php Teil 3 
Menüpunkt eintragen
<?php
if($jumpi=='write')
{
if($jumps=='schreib')
{
$wid=isset($_POST['id']) ? $_POST['id'] : '';
$wlabel=isset($_POST['label']) ? $_POST['label'] : '';
$wziel=isset($_POST['ziel']) ? $_POST['ziel'] : '';
$wlinkurl=isset($_POST['linkurl']) ? $_POST['linkurl'] : '';
$wparentid=isset($_POST['parentid']) ? $_POST['parentid'] : '';
$stmt = $pdo->prepare ("INSERT INTO test_menu (id, label, ziel, link_url, parent_id ) VALUES (:id,:label,:ziel,:linkurl,:parentid)");
$stmt->bindParam(':id',$wid,PDO::PARAM_INT);
$stmt->bindParam(':label',$wlabel,PDO::PARAM_STR);
$stmt->bindParam(':ziel',$wziel,PDO::PARAM_INT);
$stmt->bindParam(':linkurl',$wlinkurl,PDO::PARAM_STR);
$stmt->bindParam(':parentid',$wparentid,PDO::PARAM_INT);
if($stmt->execute())
{
header("Location:index.php?page=99&jump=2&jumpi=show");
}
else
{
echo"Da ist was schief gelaufen";
}
}
}
?>
hmenu.php Teil 4 
Menüpunkt editieren
<?php
if($jumpi=='recht')
{
echo'<form method="post" action="index.php?page=99&jump=2&jumpi=recht&mem_id='.$mem_id.'">';
echo'<table class="tables faces">';
echo'<tr>';
echo'<th colspan="2">Haupt-Menue Edit</th>';
echo'</tr>';
$stmt = $pdo->prepare("SELECT id,label,ziel,link_url,parent_id FROM test_menu WHERE id=:id");
$stmt->bindParam(':id',$mem_id,PDO::PARAM_INT);
$stmt->bindColumn(1,$mem_id);
$stmt->bindColumn(2,$m_label);
$stmt->bindColumn(3,$m_ziel);
$stmt->bindColumn(4,$m_link);
$stmt->bindColumn(5,$m_parid);
$stmt->execute();
while($stmt->fetch())
{
echo'<tr>';
echo'<td>ID:</td>';
echo'<td>';
echo'<input class="form-controle" type="text" name="id" value="'.$mem_id.'">';
echo'</td>';
echo'</tr>';
echo'<tr>';
echo'<td>Menüname:</td>';
echo'<td>';
echo'<input class="form-controle" type="text" name="label" value="'.$m_label.'">';
echo'</td>';
echo'</tr>';
echo'<tr>';
echo'<td>Wohin:</td>';
echo'<td>';
echo'<input class="form-controle" type="text" name="ziel" value="'.$m_ziel.'">';
echo'</td>';
echo'</tr>';
echo'<tr>';
echo'<td >Link_Url:</td>';
echo'<td>';
echo'<input class="form-controle" type="text" name="linkurl" value="'.$m_link.'">';
echo'</td>';
echo'</tr>';
echo'<tr>';
echo'<td>PaarID:</td>';
echo'<td>';
echo'<input class="form-controle" type="text" name="parentid" value="'.$m_parid.'">';
echo'</td>';
echo'</tr>';
}
echo'<td>';
echo'<input class="butli button-blue" type="submit" name="labelneu" value="Speichern">';
echo'</td>';
echo'<td>';
echo'<button class="butli" type="submit" formaction="index.php?page=99&jump=2&jumpi=show">zurück</button>';
echo'</td>';
echo '</table>';
echo'</form>';
if(isset($_POST['labelneu']))
{
$id = $mem_id;
$label = isset($_POST['label']) ? $_POST['label'] : '';
$ziel = isset($_POST['ziel']) ? $_POST['ziel'] : '';
$linkurl = isset($_POST['linkurl']) ? $_POST['linkurl'] : '';
$parent = isset($_POST['parentid']) ? $_POST['parentid'] : '';
$stmt = $pdo->prepare('UPDATE test_menu SET label=:label,ziel=:ziel,link_url=:linkurl,parent_id=:parentid WHERE id=:id');
$stmt->bindParam(':id',$id,PDO::PARAM_INT);
$stmt->bindParam(':label',$label,PDO::PARAM_STR);
$stmt->bindParam(':ziel',$ziel,PDO::PARAM_INT);
$stmt->bindParam(':linkurl',$linkurl,PDO::PARAM_STR);
$stmt->bindParam(':parentid',$parent,PDO::PARAM_INT);
if($stmt->execute())
{
header("Location:index.php?page=99&jump=2&jumpi=show");
}
else
{
echo"Da ist was schief gelaufen";
}
}
}
?>
hmenu.php Teil 5 
Menüpunkt löschen
<?php
if($jumpi=='del')
{
$stmt = $pdo->prepare("SELECT id,label,ziel,link_url,parent_id FROM test_menu WHERE id=:id");
$stmt->bindParam(':id',$mem_id,PDO::PARAM_INT);
$stmt->bindColumn(1,$mem_id);
$stmt->bindColumn(2,$m_label);
$stmt->bindColumn(3,$m_ziel);
$stmt->bindColumn(4,$m_link);
$stmt->bindColumn(5,$m_parid);
$stmt->execute();
while($stmt->fetch())
{
echo'<p class="center">Haupt-Menüpunkt <strong>'.trim($m_label).'</strong> wirklich löschen?';
echo'<a href="index.php?page=99&jump=2&jumpi=loesche&mem_id='.IntVal($mem_id).'">Ja</a> | ';
echo'<a href="index.php?page=99&jump=2&jumpi=show">Nein</a></p>';
}
}
if($jumpi=='loesche')
{
$stmt = $pdo->prepare("DELETE FROM test_menu WHERE id=:id");
$stmt->bindParam(':id',$mem_id,PDO::PARAM_INT);
if($stmt->execute())
{
header("Location:index.php?page=99&jump=2&jumpi=show");
}
else
{
echo"Da ist was schief gelaufen";
}
}
}
else
{
header("Location: index.php?page=1");
exit();
}
?>