Lieta: Ir Neliels, parasts Admina Panelis, un īsāk sakot skripts izpildās tikai līdz vietai, kur rakstīts // Līdz šejienei <<, tālāk ejot, viņš (username = $_SESSION['user']) username nomaina uzreiz uz 0 un vnk atgriezas uz admin.php lapu..
Nespēju atrisināt problēmu, varbūt kāds var palīdzēt?
Skripts:
<?php
session_start();
include("include/db.php");
$admin = mysql_fetch_array(mysql_query("SELECT * FROM user WHERE username = '".$_SESSION['user']."' "));
if($admin['level'] != '3'){
header('Location: index.php');
exit;
}
if($_GET['p'] == 'user'){
$user = mysql_query("SELECT * FROM user ORDER BY id");
while($row_user = mysql_fetch_array($user)){
echo ''.$row_user["username"].' - '.$row_user["password"].' - '.$row_user["email"].' - '.$row_user["level"].' | <a href="?p=user&labot='.$row_user["id"].'"><b>Labot</b></a><br>';
}
echo "<hr>";
// Līdz šejienei <<
if($_GET['p'] == 'user' && $_GET['labot']){
$row_user_labot = mysql_fetch_array(mysql_query("SELECT * FROM user WHERE id='".$_GET['labot']."'"));
echo "
<form method='POST' action=''>
<input type='text' name='username' value='".$row_user_labot["username"]."'><br>
<input type='text' name='password' value='".$row_user_labot["password"]."'><br>
<input type='text' name='email' value='".$row_user_labot["email"]."'><br>
<select name='level'>
<option ";if($row_user_labot["level"] == '1'){ echo "SELECTED";} echo " value='1'>Lietotājs</option>
<option ";if($row_user_labot["level"] == '2'){ echo "SELECTED";} echo " value='2'>Moderators</option>
<option ";if($row_user_labot["level"] == '3'){ echo "SELECTED";} echo " value='3'>Admins</option>
</select></br>
<input type='submit' name='user_labot' value='Labot'>
</form><hr>
";
if(isset($_POST['user_labot'])){
mysql_query("UPDATE user SET username='".$_POST['username']."', password='".$_POST['password']."', email='".$_POST['email']."', level='".$_POST['level']."' WHERE id='".$_GET['labot']."'");
header("location:admin.php");
}
}
}
?>