code_junkie

member management by admin using php

Nov 12th, 2011
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.35 KB | None | 0 0
  1. <h2><?php echo "User list"; ?></h2>
  2.  
  3. <table border="0" cellpadding="0" cellspacing="0">
  4. <tr bgcolor="#f87820">
  5. <td><img src="img/blank.gif" alt="" width="10" height="25"></td>
  6. <td class="tabhead"><img src="img/blank.gif" alt="" width="150" height="6"><br><b><?php echo "first name"; ?></b></td>
  7. <td class="tabhead"><img src="img/blank.gif" alt="" width="150" height="6"><br><b><?php echo "lastname name"; ?></b></td>
  8. <td class="tabhead"><img src="img/blank.gif" alt="" width="150" height="6"><br><b><?php echo "member id"; ?></b></td>
  9. <td class="tabhead"><img src="img/blank.gif" alt="" width="50" height="6"><br><b><?php echo "delete"; ?></b></td>
  10. <td><img src="img/blank.gif" alt="" width="10" height="25"></td>
  11. </tr>
  12.  
  13. <?php
  14.  
  15. }
  16.  
  17. $result=mysql_query("SELECT member_id,firstname,lastname,login FROM members ORDER BY firstname");
  18. $i = 0;
  19. while($row = mysql_fetch_array($result)) {
  20. if ($i > 0) {
  21. echo "<tr valign='bottom'>";
  22. echo "<td bgcolor='#ffffff' height='1' style='background-image:url(img/strichel.gif)' colspan='6'></td>";
  23. echo "</tr>";
  24. }
  25. echo "<tr valign='middle'>";
  26. echo "<td class='tabval'><img src='img/blank.gif' alt='' width='10' height='20'></td>";
  27. echo "<td class='tabval'><b>".$row['lastname']."</b></td>";
  28. echo "<td class='tabval'>".$row['firstname']." </td>";
  29. echo "<td class='tabval'>".$row['member_id']." </td>";
  30.  
  31. echo "<td class='tabval'><a onclick="return </span></a></td>";
  32. echo "<td class='tabval'></td>";
  33. echo "</tr>";
  34. $i++;
  35. }
  36.  
  37. ?>
  38.  
  39. </table>
  40.  
  41.  
  42. in this i wanna add tho more things in the table 1 to delete a member and 2 to have approved or denied option for that i made two functiom
  43.  
  44. below code is to delete
  45.  
  46. if($_REQUEST['action']=="del")
  47. {
  48. $memberId = mysql_real_Escape_string($_REQUEST['member_id']);
  49. mysql_query("DELETE FROM members WHERE member_id=$memberId");
  50. }
  51.  
  52. echo '<td><a href="http://yourwebsite/yourscriptname.php?action=del&member_id='
  53. . htmlspecialchars($row['member_id']) . '">Delete</a>';
  54. if ($row['approved'] == 0) {
  55. echo '&nbsp;<a href="http://yourwebsite/yourscriptname.php?action=approve&member_id='
  56. . htmlspecialchars($row['member_id']) . '">Approve</a>';
  57. }
  58. echo '</td>';
  59.  
  60. $member_id = 0;
  61. if (isset($_GET['member_id'])) $member_id = intval($_GET['member_id']);
  62. $action = '';
  63. if (isset($_GET['action'])) $action = $_GET['action'];
  64.  
  65. $sql = '';
  66. switch($action) {
  67. case 'approve':
  68. $sql = "UPDATE members SET approval = 1 WHERE member_id = $member_id";
  69. break;
  70. case 'delete':
  71. $sql = "DELETE FROM member WHERE member_id = $member_id";
  72. break;
  73. }
  74. if (!empty($sql) && !empty($member_id)) {
  75. // execute the sql.
  76. }
Add Comment
Please, Sign In to add comment