RaaapuLis Posted November 11, 2009 Report Share Posted November 11, 2009 (edited) 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"); } } } ?> Edited November 11, 2009 by RaaapuLis Quote Link to comment Share on other sites More sharing options...
waplet Posted November 11, 2009 Report Share Posted November 11, 2009 ?p=user&labot vai šādi izskatās tavs links? Quote Link to comment Share on other sites More sharing options...
RaaapuLis Posted November 11, 2009 Author Report Share Posted November 11, 2009 Nu vispār jau nē ;) <a href="?p=user&labot='.$row_user["id"].'"><b>Labot</b></a> No tāvar secināt ka saite izstās šādi: ?p=user&labot=1 Bet nu vispār pat ja būtu tā, kātu teiktu, tas neko nedotu, jo skripts netiek līdz tai vietai.. Vnk parāda visu lietotāj usarakstu un kad uzspiež uz Labot, tad arī sākās problēmas.. => Nika vietā - 0, un līdz ar to nekas tālāk no lietotāja opcijām neiet.. Quote Link to comment Share on other sites More sharing options...
waplet Posted November 11, 2009 Report Share Posted November 11, 2009 Man liekas viņš ir nestrukturāli pareizi uztaisīts, vai uzspiežot labot links joprojām ir tāds kādu tu atstā?un jā pamēģini sākumā kkur pierakstīt print_r($_POST); print_r($_GET); Quote Link to comment Share on other sites More sharing options...
RaaapuLis Posted November 11, 2009 Author Report Share Posted November 11, 2009 (edited) Un kam, tavuprāt, būtu jābūt tajos print_r GET un POST? p.s. TUKŠUMS taču tur ir, uzspiežot uz labot lietotājus -> ?p=user tālāk spiežot uz noteikta lietotāja - Labot, Nika vietā 0, un kr4 viss pazuud, atpakalj uz admin.php sākumu EDIT tomēŗ kļūdijos es, skripts nojūdzas, uzreiz kā uzspiež uz labot lietotājus taču citas sadaļas iet un ir veidotas pilniigi peec taada paša principa Edited November 11, 2009 by RaaapuLis Quote Link to comment Share on other sites More sharing options...
FiXeD Posted November 12, 2009 Report Share Posted November 12, 2009 Pamēģini, ko šādu <?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; }else{ 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"); } } } } ?> Quote Link to comment Share on other sites More sharing options...
RaaapuLis Posted November 12, 2009 Author Report Share Posted November 12, 2009 Tas pats :/ Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.