PHP interesse |
|
Hey,
Ik heb een admin pagina gemaakt, om de gebruikers op mijn site te beheren, nu doe ik dat met Switch, maar als ik op update klik, update hij hem wel in de database, maar dan naar lege velden.
Script:
<?php
switch($_GET['action']
{
case update:
$id = $_GET['update'];
mysql_query("UPDATE users SET name='".$_POST['uname']."', level='".$_POST['ulevel']."' WHERE id='".$id."'");
echo "Updated";
echo $back;
break;
default:
$res = mysql_query("SELECT * FROM users ORDER BY level DESC") or die(mysql_error());
while($arr = mysql_fetch_row($res))
{
?>
<form method="post" action="<?php echo $_SERVER['REQUEST_URI']."&&action=update"; ?>">
<input type="text" name="uname" value="<?php echo $arr[1]; ?>">
<select name="ulevel">
<option <?php if($arr['3'] == 2) { echo "selected"; } ?>>2
<option <?php if($arr['3'] == 1) { echo "selected"; } ?>>1
</select>
<?php
echo "<a href='".$_SERVER['REQUEST_URI']."&&del=".$arr[0]."&&action=del'>Del</a><br>";
echo "<a href='".$_SERVER['REQUEST_URI']."&&update=".$arr[0]."&&action=update'>Update</a><br>";
echo "</form> ";
}
break;
}
?>
<?php switch($_GET['action'] { case update: $id = $_GET['update']; mysql_query("UPDATE users SET name='".$_POST['uname']."', level='".$_POST['ulevel']."' WHERE id='".$id."'"); break; default: { ?> <form method="post" action=" <?php echo $_SERVER['REQUEST_URI']."&&action=update"; ?>"> <input type="text" name="uname" value=" <?php echo $arr[1]; ?>"> <select name="ulevel"> <option <?php if($arr['3'] == 2) { echo "selected"; } ?>>2 <option <?php if($arr['3'] == 1) { echo "selected"; } ?>>1 </select> <?php echo "<a href='".$_SERVER['REQUEST_URI']."&&del=".$arr[0]."&&action=del'>Del</a><br>"; echo "<a href='".$_SERVER['REQUEST_URI']."&&update=".$arr[0]."&&action=update'>Update</a><br>"; } break; } ?>
Weet iemand wat ik verkeerd doe?
|