deleting member

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    how to deleting member

    Hi all i am new to all this and looking for a bit of help please and i am sorry if i have posted this in the wrong part of the site


    i am trying to add a bit where you can delete a member from a forum site i have made

    This is data base

    PHP Code:
    CREATE TABLE `users` (
      `
    idbigint(20NOT NULL,
      `
    usernamevarchar(255NOT NULL,
      `
    passwordvarchar(255NOT NULL,
      `
    emailvarchar(255NOT NULL,
      `
    avatartext NOT NULL,
      `
    signup_dateint(10NOT NULL
    ENGINE=MyISAM DEFAULT CHARSET=utf8
    this is where it shows members

    PHP Code:
    <?php
    include('config.php');
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
            <link href="<?php echo $design?>/style.css" rel="stylesheet" title="Style" />
            <title>List of users</title>
        </head>
        <body>
         <div class="header">
             <a href="<?php echo $url_home?>"><img src="<?php echo $design?>/images/logo.png" alt="Members Area" /></a>
       </div>
            <div class="content">
    This is the list of members:
    <table>
        <tr>
         <th>Id</th>
         <th>Username</th>
         <th>Email</th>
        </tr>
    <?php
    //We get the IDs, usernames and emails of users
    $req mysql_query('select id, username, email from users');
    while(
    $dnn mysql_fetch_array($req))
    {
    ?>
    <tr>
         <td class="left"><?php echo $dnn['id']; ?></td>
         <td class="left"><a href="profile.php?id=<?php echo $dnn['id']; ?>"><?php echo htmlentities($dnn['username'], ENT_QUOTES'UTF-8'); ?></a></td>
         <td class="left"><?php echo htmlentities($dnn['email'], ENT_QUOTES'UTF-8'); ?></td>
    <td class="left"><a href="delete_member.php?id=<?php echo $dnn1['id']; ?>"><img src="<?php echo $design?>/images/delete.png" alt="Delete" /></a></td>
        </tr>
    <?php
    }
    ?>
    </table>
    </div>
    <div class="foot"><a href="<?php echo $url_home?>">Go Home</a> </div>
    </body>
    </html>
    this is the page when you have deleted a member
    PHP Code:
    <?php
    //This page let delete a member
    include('config.php');
    if(isset(
    $_GET['id']))
    {
    $id intval($_GET['id']);
    $dn1 mysql_fetch_array(mysql_query('select count(id) as nb1, username from id where id="'.$id.'" group by id'));
    if(
    $dn1['nb1']>0)
    {
    if(isset(
    $_SESSION['username']) and $_SESSION['username']==$admin)
    {
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
            <link href="<?php echo $design?>/style.css" rel="stylesheet" title="Style" />
            <title>Delete a member - <?php echo htmlentities($dn1['usernamename'], ENT_QUOTES'UTF-8'); ?> - Forum</title>
        </head>
        <body>
         <div class="header">
             <a href="<?php echo $url_home?>"><img src="default/images/logo.png" alt="Forum" /></a>
       </div>
            <div class="content">
    <?php
    $nb_new_pm 
    mysql_fetch_array(mysql_query('select count(*) as nb_new_pm from pm where ((user1="'.$_SESSION['userid'].'" and user1read="no") or (user2="'.$_SESSION['userid'].'" and user2read="no")) and id2="1"'));
    $nb_new_pm $nb_new_pm['nb_new_pm'];
    ?>
    <div class="box">
    <div class="box_left">
         <a href="<?php echo $url_home?>">Forum Index</a> &gt; <?php echo htmlentities($dn1['username'], ENT_QUOTES'UTF-8'); ?> &gt; Delete the category
        </div>
    <div class="box_right">
         <a href="list_pm.php">Your messages(<?php echo $nb_new_pm?>)</a> - <a href="profile.php?id=<?php echo $_SESSION['userid']; ?>"><?php echo htmlentities($_SESSION['username'], ENT_QUOTES'UTF-8'); ?></a> (<a href="login.php">Logout</a>)
        </div>
        <div class="clean"></div>
    </div>
    <?php
    if(isset($_POST['confirm']))
    {
    if(
    mysql_query('delete from username where id="'.$id.'"') and mysql_query('delete from username where parent="'.$id.'"'))
    {
    ?>
    <div class="message">The member have successfully been deleted.<br />
    <a href="<?php echo $url_home?>">Go to the forum index</a></div>
    <?php
    }
    else
    {
    echo 
    'An error occured while deleting Member.';
    }
    }
    else
    {
    ?>
    <form action="delete_member.php?id=<?php echo $id?>" method="post">
    Are you sure you want to delete this member?
        <input type="hidden" name="confirm" value="true" />
        <input type="submit" value="Yes" /> <input type="button" value="No" onclick="javascript:history.go(-1);" />
    </form>
    <?php
    }
    ?>
    </div>
    <div class="foot"><a href="https://twitter.com/"><img src="../images/t.png"  width="100" height="85" alt="?????"></a><a href="https://www.facebook.com/"><img src="../images/f.png"  width="100" height="85" alt="??????"></a><br><br>Copyright site name &copy; 2014. Designed by <a href="http://urswebdesign.co.uk/copyright.html">urswebdesign</a></div>
    </body>
    </html>
    <?php
    }
    else
    {
    echo 
    '<h2>You must be logged as an administrator to access this page: <a href="login.php">Login</a> - <a href="signup.php">Sign Up</a></h2>';
    }
    }
    else
    {
    echo 
    '<h2>The member you want to delete doesn\'t exist.</h2>';
    }
    }
    else
    {
    echo 
    '<h2>The ID of the member you want to delete is not defined.</h2>';
    }
    ?>
    all i get is

    PHP Code:
    The member you want to delete doesn't exist. 

    i am greatful of all the help if anyone can help me please thanks very much

    #2
    Why don't you use this code:
    PHP Code:
    $dn0 mysql_query("SELECT id, username FROM id WHERE id='$id'");
    $icount mysql_num_rows($dn0);
    $dn1 mysql_fetch_array($dn0);
    if(
    $icount!=0
    instead of:
    PHP Code:
    $dn1 mysql_fetch_array(mysql_query('select count(id) as nb1, username from id where id="'.$id.'" group by id'));
    if(
    $dn1['nb1']>0

    Comment


      #3
      Originally posted by asifnayem View Post
      Why don't you use this code:
      PHP Code:
      $dn0 mysql_query("SELECT id, username FROM id WHERE id='$id'");
      $icount mysql_num_rows($dn0);
      $dn1 mysql_fetch_array($dn0);
      if(
      $icount!=0
      instead of:
      PHP Code:
      $dn1 mysql_fetch_array(mysql_query('select count(id) as nb1, username from id where id="'.$id.'" group by id'));
      if(
      $dn1['nb1']>0
      Your idea is great but your query will not do so..

      instead of
      Code:
      SELECT id, username FROM id WHERE id='$id'
      use this query
      Code:
       SELECT id, username FROM users WHERE id='$id'

      but I prefer this, much simpler than selecting id's and deleting you can directly delete users using WHERE
      Code:
      DELETE FROM users WHERE id='$id'
      Last edited by wapxtech; 29.09.14, 15:31.

      http://wapx.amob.com
      Applications, Games, Wallpapers, Ringtones, Videos, Themes, Screensaver and More!!!

      Comment

      Working...
      X