Advanced Search

Results 1 to 2 of 2

Thread: Not getting the variable value after isset

  1. #1
    Join Date
    May 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Not getting the variable value after isset

    hi all,
    i am a new bee.i had a problem. I had a text box and i need that value after isset so before isset if echo then i am getting that value but after this isset i am not getting it.so can any one. u can understand after seeing my code.
    Code:
    1. <html>
    2. <body>
    3. <?php
    4. $id=$_GET['f1'];
    5. include 'connection.php';
    6. $query="select * from users where userid='$id'";
    7. mysql_error();
    8. $result = mysql_query ($query) ;
    9. $num=mysql_num_rows($result);
    10. $i=0;
    11. While($i < $num)
    12. {
    13. $userid=mysql_result($result,$i,"userid");
    14. $sqlusername=mysql_result($result,$i,"username");
    15. $password=mysql_result($result,$i,'password');
    16. $role=mysql_result($result,$i,"role");
    17. $status=mysql_result($result,$i,'status');
    18. //$reportingto=mysql_result($result,$i,'reportingto');
    19. $allocatedmemory=mysql_result($result,$i,"allocatedmemory");
    20. $arr_id=split("[{ }-]" ,$allocatedmemory);
    21. $i++;
    22. }
    23. ?>
    24. <form action="update.php" method="post">
    25. <div>
    26. <center>
    27. <table>
    28. <tr>
    29. <td style="color: navy;">Userid</td>
    30. <td><input type="text" readonly="readonly" name="userid" value="<? echo $userid; ?>"></td>
    31. </tr>
    32. <tr>
    33. <td style="color: navy;">Username</td>
    34. <td><input type="text" name="username" id="txtname" value="<? echo $sqlusername; ?>"></td>
    35. </tr>
    36. <tr>
    37. <td style="color: navy;">Password</td>
    38. <td><input type="password" name="password" id="pwd" value="<? echo $password; ?>"></td>
    39. </tr><tr>
    40. <td style="color: navy;">Status:</td>
    41. <td><select name="status">
    42. <?php
    43. if($status == 1)
    44. {
    45. echo '<option value="Active" selected="selected">Active</option>';
    46. echo '<option value="Inactive">Inactive</option>';
    47. }
    48. else
    49. {
    50. echo '<option value="Inactive" selected="selected">Inactive</option>';
    51. echo '<option value="Active">Active</option>';
    52. }
    53. ?>
    54. </select></td></tr>
    55. <tr>
    56. <td style="color: navy;">Allocatedmemory</td>
    57. <td><input type="text" onkeypress="return isNumberKey(event)" id="am" name="allocatedmemory" value="<? echo $arr_id[0]; ?>"></td>
    58. <td><select name="size">
    59. <?php
    60. if($arr_id[1]== "KB")
    61. {
    62. echo '<option value="MB">MB</option>';
    63. echo '<option value="KB" selected="selected">KB</option>';
    64. }
    65. else
    66. {
    67. echo '<option value="MB" selected="selected">MB</option>';
    68. echo '<option value="KB">KB</option>';
    69. }?>
    70. </select>
    71. </td>
    72. </tr>
    73. <tr>
    74. <td></td>
    75. <td><input type="submit" name="btn" value="Update" onclick="return (confirm('Are you sure you want to Update this?'),check())"/>
    76. <input type="submit" name="btn" value="Delete" onclick="return (confirm('Are you sure you want to delete this?'))"/></td>
    77. </tr>
    78. </table>
    79. </center>
    80. </div>
    81. </form>
    82. </body>
    83. </html>
    84. <?php
    85. $user=$sqlusername;
    86. echo $user;
    87. if(isset($_POST['btn']))
    88. {
    89. include 'connection.php';
    90. if($_POST[btn]== 'Update')
    91. {
    92. $pname=$_POST['username'];
    93. if($_POST[status] == 'Active')
    94. $_POST[status] = 1;
    95. else{
    96. $_POST[status] = 0;
    97. }
    98. echo $pname;
    99. if($user==$pname)
    100. {
    101. mysql_query("UPDATE users SET username = '$_POST[username]',password = '$_POST[password]', role = '1', status = $_POST[status], allocatedmemory = '$_POST[allocatedmemory] $_POST[size]' WHERE userid = '$_POST[userid]'");
    102. echo "<script language='javascript'>
    103. alert('User details updated');
    104. </script>";
    105. echo "<script language='javascript' type='text/javascript'>
    106. window.close();
    107. </script>";
    108. }
    109. else{
    110. $query="select * from users where username='$pname'";
    111. mysql_error();
    112. $result=mysql_query($query);
    113. $count=mysql_num_rows($result);
    114. if($count==0)
    115. {
    116. mysql_query("UPDATE users SET username = '$_POST[username]',password = '$_POST[password]', role = '1', status = $_POST[status], allocatedmemory = '$_POST[allocatedmemory] $_POST[size]' WHERE userid = '$_POST[userid]'");
    117. }
    118. else
    119. {
    120. echo "<script language='javascript'>
    121. alert('Username already exists');
    122. </script>";
    123. }
    124. }
    125. }
    126. else if($_POST[btn] == 'Delete')
    127. {
    128. mysql_query("Delete from users where userid ='$_POST[userid]'");
    129. echo "<script language='javascript'>
    130. alert('Data Deleted');
    131. </script>";
    132. echo "<script language='javascript' type='text/javascript'>
    133. window.close();
    134. </script>";
    135. }
    136. }
    137. ?>
    This is a big code as it is difficult to see all this,i can make it small for u to make clear my problem.so see the line no.14,34,85,86,92,99.
    so wat i need to get is the value of line 86 after line 87. so that my condition in line no.99 can work
    Thank u.

  2. #2
    Join Date
    May 2010
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Can i see a screenshot of your database or something or a sql file so i can use it on my own pc, just to check the field names and stuff.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •