A community in which webmasters can ask for help with topics such as PHP coding , MySQL , IT jobs, web design, IT security.
Current location:homephp forumphp talk in 2008 yearmember management by admin using php - page 1
User InfoPosts
member management by admin using php#1
Sorry for asking an implement my feature question type question last time. I am new to Stackoverflow.com and also to php that's why.

What I was trying to ask is:

I have made a admin account. Members have registration page so a member will register. When user registers in the database table I will have a field for which 0 value will be initialised which means he is not approved. In admin account I have code to get the list of members. The code is given below:

<h2><?php echo "User list"; ?></h2>

<table border="0" cellpadding="0" cellspacing="0">
<tr bgcolor="#f87820">
<td><img src="img/blank.gif" alt="" width="10" height="25"></td>
<td class="tabhead"><img src="img/blank.gif" alt="" width="150" height="6"><br><b><?php echo "first name"; ?></b></td>
<td class="tabhead"><img src="img/blank.gif" alt="" width="150" height="6"><br><b><?php echo "lastname name"; ?></b></td>
<td class="tabhead"><img src="img/blank.gif" alt="" width="150" height="6"><br><b><?php echo "member id"; ?></b></td>
<td class="tabhead"><img src="img/blank.gif" alt="" width="50" height="6"><br><b><?php echo "delete"; ?></b></td>
<td><img src="img/blank.gif" alt="" width="10" height="25"></td>



$result=mysql_query("SELECT member_id,firstname,lastname,login FROM members ORDER BY firstname");
$i = 0;
while($row = mysql_fetch_array($result)) {
if ($i > 0) {
echo "<tr valign='bottom'>";
echo "<td bgcolor='#ffffff' height='1' style='background-image:url(img/strichel.gif)' colspan='6'></td>";
echo "</tr>";
echo "<tr valign='middle'>";
echo "<td class='tabval'><img src='img/blank.gif' alt='' width='10' height='20'></td>";
echo "<td class='tabval'><b>".$row['lastname']."</b></td>";
echo "<td class='tabval'>".$row['firstname']." </td>";
echo "<td class='tabval'>".$row['member_id']." </td>";

echo "<td class='tabval'><a onclick=\"return </span></a></td>";
echo "<td class='tabval'></td>";
echo "</tr>";



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

below code is to delete

$memberId = mysql_real_Escape_string($_REQUEST['member_id']);
mysql_query("DELETE FROM members WHERE member_id=$memberId");

below one for approving members

But my problem is I don't know how to include a button or radio button in the table which can pass value delete or approve to these functions.

Please tell me how the syntax is to add this button so that for approving I can change the value 0 that I gave in the database to 1 so that member get approved.

posted date: 2008-12-11 19:50:00

Re: member management by admin using php#2
I had made out the solution of this problem. click to view my topic...

hope that hepls.

posted date: 2008-12-11 19:50:01

Re: member management by admin using php#3
What I would do is to set up a form inside of the table.?> <form name="deleteUser" id="deleteUser" method="post" action=""><input type="hidden" name="member_id" id="member_id" value="<?php echo $row['member_id'] ?><input type="submit" name="action" id="action" value="del" /></form><?phpI would insert that in between your <td> tag. <td class='tabval'>INSERT HERE</td>";

posted date: 2008-12-11 20:01:00

Re: member management by admin using php#4
Try this:echo '<td><a href="http://yourwebsite/yourscriptname.php?action=del&amp;member_id=' . htmlspecialchars($row['member_id']) . '">Delete</a>';if ($row['approved'] == 0) { echo '&nbsp;<a href="http://yourwebsite/yourscriptname.php?action=approve&amp;member_id=' . htmlspecialchars($row['member_id']) . '">Approve</a>';}echo '</td>';And make sure ALL of your database values are being sent to the browser in htmlspecialchars().On the flipside,$member_id = 0;if (isset($_GET['member_id'])) $member_id = intval($_GET['member_id']);$action = '';if (isset($_GET['action'])) $action = $_GET['action'];$sql = '';switch($action) {case 'approve': $sql = "UPDATE members SET approval = 1 WHERE member_id = $member_id"; break;case 'delete': $sql = "DELETE FROM member WHERE member_id = $member_id"; break;}if (!empty($sql) && !empty($member_id)) { // execute the sql.}

posted date: 2008-12-11 20:11:00

select page: « 1 »
Copyright ©2008-2017 www.momige.com, all rights reserved.