function edit_user($username){
if ( $username == 'admin' ) {
$query = "SELECT * FROM login WHERE username != 'admin'";
$queryResult = mysql_query($query) or die (mysql_error());
echo "<table border='1'>
<tr>
<th>Loginid</th>
<th>username</th>
<th>email</th>
<th>activated</th>
<th>Edit User</th>
<th>Delete user</th>
</tr>";
while($rows = mysql_fetch_array($queryResult)) {
//Todo: Here is a problem
//probably use mysql_num_array function...gonna fix that this.
//
// $_SESSION['username'] = $rows['username'];
echo "<tr>";
echo "<td bgcolor='#FF9933'>". $rows['loginid'] . "</td>";
echo "<td bgcolor='#FF9933'>" . $rows['username'] . "</td>";
echo "<td bgcolor='#FF9933'>" . $rows['email'] . "</td>";
echo "<td bgcolor='#FF9933'>" . $rows['activated'] . "</td>";
echo "<td bgcolor='#FFFFFF'><center>" . '<input type="button" name="Activate" value="Activate" class="form"
onClick="activate_user_id('.$rows['username'].','.$rows['loginid'].','.$rows['activated'].')">' . "</center></td>";
echo "<td bgcolor='#FFFFFF'><center>" . '<input type="submit" name="Delete" value="Delete" class="form"
onClick="delete_user('.$rows['username'].','.$rows['loginid'].','.$rows['activated'].')">' . "</center></td>";
echo "</tr>";
}
echo "</table>";
}else {
echo "$username";
echo "<p>You dont have permission to access the Admin site</p>";
}
}
function activate_user_id ($username, $loginid, $activated) {
global $seed;
if (!valid_username($username) || !user_exists($username))
{
return false;
}
$query = sprintf("select activated from login where username = '%s' and loginid = '%s' and activated = '%s' limit 1",
mysql_real_escape_string($username), mysql_real_escape_string($loginid));
$result = mysql_query($query);
if (mysql_num_rows($result) == 1)
{
$sql = sprintf("update login set username = 'eric15' where username ='%s' and loginid = '%s' and activated = '%s'",
mysql_real_escape_string($username), mysql_real_escape_string($loginid));
return true;
}
}
function delete_user ($username, $loginid, $activated) {
$query = sprintf("select activated from login where username = '%s' and loginid = '%s' and activated = '%s' limit 1",
mysql_real_escape_string($username), mysql_real_escape_string($loginid));
$result = mysql_query($query);
if (mysql_num_rows($result) == 1)
{
$sql = sprintf("delete from login where username = '%s' and loginid = '%s' and activated = '%s'",
mysql_real_escape_string($username), mysql_real_escape_string($loginid));
}
}
ericxye 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.