php coding help required

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

    php coding help required

    hello i have a forum and on the forum i can delete the users from it but that dose not delete them from the main members page also i wanted to intergrate it.

    i have some code but this dont work


    please help im tearing my hair out

    my user board table is b_users

    my main memebrs table is usersgnet

    $deluser="DELETE from b_users where userID='$userid'";
    mysql_query($deluser) or die("Could not delete user");


    $del="DELETE * from usersgnet where name='$username'";
    mysql_query($del) or die ("error in deletion");


    have no idea please help

    rich :-)

    #2
    PHP Code:
    <?php
    $query 
    sprintf("DELETE from b_users where userID='$userid'",mysql_real_escape_string($userid));
    $result mysql_query($query);
    if (!
    $result) {
        
    $message  'Invalid query: ' mysql_error() . "\n";
        
    $message .= 'Whole query: ' $query;
        die(
    $message);
    }
    mysql_free_result($result);
    ?>
    Visit: Chat4u.mobi - The New Lay Of being a site of your dreams!
    Visit: WapMasterz Coming Back Soon!
    _______
    SCRIPTS FOR SALE BY SUBZERO
    Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders.
    FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others...
    _______
    Info & Tips
    php.net
    w3schools.com

    Comment


      #3
      nice one subzro.

      but the b_users one works as its not a script im writeing.

      i need to also delete out of the usergnet record.

      im new to php and cant write it but can read if you know what i mean

      $del="DELETE * from usersgnet where name='$username'";
      mysql_query($del) or die ("error in deletion");

      this is what im trying to get working i need to match the user fro one table to another table and then delte from both tables can this be done?

      thanks again for your quick responce.


      this is the whole page

      <?PHP
      session_start();
      include ('http://gnetuk.net/dbc.php');
      include "connect.php";


      $user=$_SESSION['user'];
      $selectuser="SELECT * from b_users a, b_templates b where b.templateid=a.templateclass and a.username='$user'";
      $selectuser2=mysql_query($selectuser);
      $selectuser3=mysql_fetch_array($selectuser2);
      print "<link rel='stylesheet' href='../templates/$selectuser3[templatepath]/style.css' type='text/css'>";

      if ($selectuser3[status]>=3)
      {
      print "<table border='0' class='maintable'>";
      print "<tr><td valign='top'><center>";
      print "<table width='70%' border='0'>";
      print "<tr class='headline'><td>Admin Options";
      print "</td></tr>";
      print "<tr class='forumrow'><td>";
      include "adminleft.php";
      print "</td></tr></table></center></td>";
      print "<td valign='top' width='75%'><p align='left'>";
      print "<table width='70%' border='0'>";
      print "<tr class='headline'><td>Delete User";
      print "</td></tr>";
      print "<tr class='forumrow'><td>";
      if(isset($_POST['submit']))
      {
      $userid=$_POST['userid'];
      $getuserinfo="SELECT * from b_users where userID='$userid'";
      $getuserinfo2=mysql_query($getuserinfo) or die("Could not grab user info");
      $getuserinfo3=mysql_fetch_array($getuserinfo2);
      if($selectuser3[status]>$getuserinfo3[status])
      {
      $getguestaccount="SELECT * from b_users where username='Guest'";
      $getguestaccount2=mysql_query($getguestaccount) or die("Could not get guest account");
      $getguestaccount3=mysql_fetch_array($getguestaccou nt2);
      $updateposts="Update b_posts set author='$getguestaccount3[userID]' where author='$userid'";
      mysql_query($updateposts);
      $deluser="DELETE from b_users where userID='$userid'";
      mysql_query($deluser) or die("Could not delete user");


      $del="DELETE id from usersgnet where name='$username'"; ///this is the part im tring to do the rest works fine
      mysql_query($del) or die ("error in deletion");

      print "User deleted";
      }
      else
      {
      print "Only the head admin can delete other admins";
      }
      }
      else if(isset($_GET['userID']))
      {
      $userID=$_GET['userID'];
      print "<form action='deleteuser.php' method='post'>";
      print "Are you sure you want to delete this user?(Delete a user will reset posts in his name to 'Guest')<br>";
      print "<input type='hidden' name='userid' value='$userID'>";
      print "<input type='submit' name='submit' value='Delete This user'></form>";

      }
      else
      {
      print "You did not select a user to delete";

      }
      print "</td></tr></table></p>";
      print "</td></tr></table>";
      print "</center>";
      }
      else
      {
      print "<table width='70%' border='0'>";
      print "<tr class='headline'><td><center>Not logged in as Admin</td></tr>";
      print "<tr class='forumrow'><td>";
      print "You are not logged in as Administrator, please log in.";
      print "<form method='POST' action='../authenticate.php'>";
      print "Type Username Here: <input type='text' name='username' size='15'><br>";
      print "Type Password Here: <input type='password' name='password' size='15'><br>";
      print "<input type='submit' value='submit' name='submit'>";
      print "</form>";
      print "</td></tr></table>";
      }

      ?>
      Last edited by ares1981; 17.09.11, 11:07.

      Comment


        #4
        Using search the data base you can use %s% in your site like %$username% as your looking

        eg: userid='".%search%."'
        Visit: Chat4u.mobi - The New Lay Of being a site of your dreams!
        Visit: WapMasterz Coming Back Soon!
        _______
        SCRIPTS FOR SALE BY SUBZERO
        Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders.
        FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others...
        _______
        Info & Tips
        php.net
        w3schools.com

        Comment


          #5
          Originally posted by subzero View Post
          Using search the data base you can use %s% in your site like %$username% as your looking

          eg: userid='".%search%."'
          username='%".$search."%'
          Advertise your mobile site for FREE with AdTwirl

          Comment


            #6
            lol, thanks bro making that right lol i was doing thing on the side with my site
            Visit: Chat4u.mobi - The New Lay Of being a site of your dreams!
            Visit: WapMasterz Coming Back Soon!
            _______
            SCRIPTS FOR SALE BY SUBZERO
            Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders.
            FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others...
            _______
            Info & Tips
            php.net
            w3schools.com

            Comment


              #7
              Try this way,
              PHP Code:
               $sel="SELECT id from usersgnet where name='$username'";
               
              $select=mysql_query($sel) or die ("error");
               
              $selected=mysql_fetch_array($select);
               
               
              $del="DELETE id from usersgnet where id='$selected[0]'"///this is the part im tring to do the rest works fine
               
              mysql_query($del) or die ("error in deletion"); 
              Or add while loop, i didn't sure that understand what are the symptoms actually. :D
              Last edited by arnage; 17.09.11, 15:22.
              <!DOCTYPE html PUBLIC "-//WAPFORUM.RS

              Comment


                #8
                <?PHP
                include "connect.php";
                session_start();
                $user=$_SESSION['user'];
                $selectuser="SELECT * from b_users a, b_templates b where b.templateid=a.templateclass and a.username='$user'";
                $selectuser2=mysql_query($selectuser);
                $selectuser3=mysql_fetch_array($selectuser2);
                print "<link rel='stylesheet' href='../templates/$selectuser3[templatepath]/style.css' type='text/css'>";
                if ($selectuser3[status]>=3)
                {
                print "<table border='0' class='maintable'>";
                print "<tr><td valign='top'><center>";
                print "<table width='70%' border='0'>";
                print "<tr class='headline'><td>Admin Options";
                print "</td></tr>";
                print "<tr class='forumrow'><td>";
                include "adminleft.php";
                print "</td></tr></table></center></td>";
                print "<td valign='top' width='75%'><p align='left'>";
                print "<table width='70%' border='0'>";
                print "<tr class='headline'><td>Delete User";
                print "</td></tr>";
                print "<tr class='forumrow'><td>";
                if(isset($_POST['submit']))
                {


                $username=$_POST['name'];
                $sel="SELECT * from usersgnet where name='$username'";
                $select=mysql_query($sel) or die ("error");
                $selected=mysql_fetch_array($select);
                $del="DELETE from usersgnet where name='$selected[0]'"; ///this is the part im tring to do the rest works fine
                mysql_query($del) or die ("error in life");


                $userid=$_POST['userid'];
                $getuserinfo="SELECT * from b_users where userID='$userid'";
                $getuserinfo2=mysql_query($getuserinfo) or die("Could not grab user info");
                $getuserinfo3=mysql_fetch_array($getuserinfo2);
                if($selectuser3[status]>$getuserinfo3[status])
                {
                $getguestaccount="SELECT * from b_users where username='Guest'";
                $getguestaccount2=mysql_query($getguestaccount) or die("Could not get guest account");
                $getguestaccount3=mysql_fetch_array($getguestaccou nt2);
                $updateposts="Update b_posts set author='$getguestaccount3[userID]' where author='$userid'";
                mysql_query($updateposts);
                $deluser="DELETE from b_users where userID='$userid'";
                mysql_query($deluser) or die("Could not delete user");



                print "User deleted";
                }
                else
                {
                print "Only the head admin can delete other admins";
                }
                }
                else if(isset($_GET['userID']))
                {
                $userID=$_GET['userID'];
                print "<form action='deleteuser.php' method='post'>";
                print "Are you sure you want to delete this user?(Delete a user will reset posts in his name to 'Guest')<br>";
                print "<input type='hidden' name='userid' value='$userID'>";
                print "<input type='submit' name='submit' value='Delete This user'></form>";
                }
                else
                {
                print "You did not select a user to delete";
                }
                print "</td></tr></table></p>";
                print "</td></tr></table>";
                print "</center>";
                }
                else
                {
                print "<table width='70%' border='0'>";
                print "<tr class='headline'><td><center>Not logged in as Admin</td></tr>";
                print "<tr class='forumrow'><td>";
                print "You are not logged in as Administrator, please log in.";
                print "<form method='POST' action='../authenticate.php'>";
                print "Type Username Here: <input type='text' name='username' size='15'><br>";
                print "Type Password Here: <input type='password' name='password' size='15'><br>";
                print "<input type='submit' value='submit' name='submit'>";
                print "</form>";
                print "</td></tr></table>";
                }
                ?>




                this will delete the b_users member record but not the usersgnet record im so stuck.

                Comment


                  #9
                  Yes because u have changed the query:
                  PHP Code:
                  <?PHP
                   
                  include "connect.php";
                   
                  session_start();
                   
                  $user=$_SESSION['user'];
                   
                  $selectuser="SELECT * from b_users a, b_templates b where b.templateid=a.templateclass and a.username='$user'";
                   
                  $selectuser2=mysql_query($selectuser);
                   
                  $selectuser3=mysql_fetch_array($selectuser2);
                   print 
                  "<link rel='stylesheet' href='../templates/$selectuser3[templatepath]/style.css' type='text/css'>";
                   if (
                  $selectuser3[status]>=3)
                   {
                   print 
                  "<table border='0' class='maintable'>";
                   print 
                  "<tr><td valign='top'><center>";
                   print 
                  "<table width='70%' border='0'>";
                   print 
                  "<tr class='headline'><td>Admin Options";
                   print 
                  "</td></tr>";
                   print 
                  "<tr class='forumrow'><td>";
                   include 
                  "adminleft.php";
                   print 
                  "</td></tr></table></center></td>";
                   print 
                  "<td valign='top' width='75%'><p align='left'>";
                   print 
                  "<table width='70%' border='0'>";
                   print 
                  "<tr class='headline'><td>Delete User";
                   print 
                  "</td></tr>";
                   print 
                  "<tr class='forumrow'><td>";
                   if(isset(
                  $_POST['submit']))
                   {


                   
                  $username=$_POST['name']; 
                   
                  $sel="SELECT id from usersgnet where name='$username'"
                   
                  $select=mysql_query($sel) or die ("error"); 
                   
                  $selected=mysql_fetch_array($select); 
                    
                   
                  $del="DELETE id from usersgnet where id='$selected[0]'"///this is the part im tring to do the rest works fine 
                   
                  mysql_query($del) or die ("error in deletion"); 


                   
                  $userid=$_POST['userid'];
                   
                  $getuserinfo="SELECT * from b_users where userID='$userid'";
                   
                  $getuserinfo2=mysql_query($getuserinfo) or die("Could not grab user info");
                   
                  $getuserinfo3=mysql_fetch_array($getuserinfo2);
                   if(
                  $selectuser3[status]>$getuserinfo3[status])
                   {
                   
                  $getguestaccount="SELECT * from b_users where username='Guest'";
                   
                  $getguestaccount2=mysql_query($getguestaccount) or die("Could not get guest account");
                   
                  $getguestaccount3=mysql_fetch_array($getguestaccou nt2);
                   
                  $updateposts="Update b_posts set author='$getguestaccount3[userID]' where author='$userid'";
                   
                  mysql_query($updateposts);
                   
                  $deluser="DELETE from b_users where userID='$userid'";
                   
                  mysql_query($deluser) or die("Could not delete user");



                   print 
                  "User deleted";
                   }
                   else
                   {
                   print 
                  "Only the head admin can delete other admins";
                   }
                   }
                   else if(isset(
                  $_GET['userID']))
                   { 
                   
                  $userID=$_GET['userID'];
                   print 
                  "<form action='deleteuser.php' method='post'>";
                   print 
                  "Are you sure you want to delete this user?(Delete a user will reset posts in his name to 'Guest')<br>";
                   print 
                  "<input type='hidden' name='userid' value='$userID'>";
                   print 
                  "<input type='submit' name='submit' value='Delete This user'></form>";
                   }
                   else
                   {
                   print 
                  "You did not select a user to delete";
                   }
                   print 
                  "</td></tr></table></p>";
                   print 
                  "</td></tr></table>"
                   print 
                  "</center>";
                   }
                   else
                   {
                   print 
                  "<table width='70%' border='0'>";
                   print 
                  "<tr class='headline'><td><center>Not logged in as Admin</td></tr>";
                   print 
                  "<tr class='forumrow'><td>";
                   print 
                  "You are not logged in as Administrator, please log in.";
                   print 
                  "<form method='POST' action='../authenticate.php'>";
                   print 
                  "Type Username Here: <input type='text' name='username' size='15'><br>";
                   print 
                  "Type Password Here: <input type='password' name='password' size='15'><br>";
                   print 
                  "<input type='submit' value='submit' name='submit'>";
                   print 
                  "</form>";
                   print 
                  "</td></tr></table>";
                   }
                   
                  ?>
                  <!DOCTYPE html PUBLIC "-//WAPFORUM.RS

                  Comment


                    #10
                    <?PHP
                    include "connect.php";
                    session_start();
                    $user=$_SESSION['user'];
                    $selectuser="SELECT * from b_users a, b_templates b where b.templateid=a.templateclass and a.username='$user'";
                    $selectuser2=mysql_query($selectuser);
                    $selectuser3=mysql_fetch_array($selectuser2);
                    print "<link rel='stylesheet' href='../templates/$selectuser3[templatepath]/style.css' type='text/css'>";

                    if ($selectuser3[status]>=3)
                    {
                    print "<table border='0' class='maintable'>";
                    print "<tr><td valign='top'><center>";
                    print "<table width='70%' border='0'>";
                    print "<tr class='headline'><td>Admin Options";
                    print "</td></tr>";
                    print "<tr class='forumrow'><td>";
                    include "adminleft.php";
                    print "</td></tr></table></center></td>";
                    print "<td valign='top' width='75%'><p align='left'>";
                    print "<table width='70%' border='0'>";
                    print "<tr class='headline'><td>Delete User";
                    print "</td></tr>";
                    print "<tr class='forumrow'><td>";
                    if(isset($_POST['submit']))
                    {

                    $username=$_POST['name'];
                    $sel="SELECT id from usersgnet where name='$username'";
                    $select=mysql_query($sel) or die(mysql_error());
                    $selected=mysql_fetch_array($select);

                    $del="DELETE id from usersgnet where id='$selected[0]'"; ///this is the part im tring to do the rest works fine
                    mysql_query($del) or die(mysql_error());

                    $userid=$_POST['userid'];
                    $getuserinfo="SELECT * from b_users where userID='$userid'";
                    $getuserinfo2=mysql_query($getuserinfo) or die("Could not grab user info");
                    $getuserinfo3=mysql_fetch_array($getuserinfo2);
                    if($selectuser3[status]>$getuserinfo3[status])
                    {
                    $getguestaccount="SELECT * from b_users where username='Guest'";
                    $getguestaccount2=mysql_query($getguestaccount) or die("Could not get guest account");
                    $getguestaccount3=mysql_fetch_array($getguestaccou nt2);
                    $updateposts="Update b_posts set author='$getguestaccount3[userID]' where author='$userid'";
                    mysql_query($updateposts);
                    $deluser="DELETE from b_users where userID='$userid'";
                    mysql_query($deluser) or die("Could not delete user");
                    print "User deleted";
                    }
                    else
                    {
                    print "Only the head admin can delete other admins";
                    }
                    }
                    else if(isset($_GET['userID']))
                    {
                    $userID=$_GET['userID'];
                    print "<form action='deleteuser.php' method='post'>";
                    print "Are you sure you want to delete this user?(Delete a user will reset posts in his name to 'Guest')<br>";
                    print "<input type='hidden' name='userid' value='$userID'>";
                    print "<input type='hidden' name='name' value='$name'>";
                    print "<input type='submit' name='submit' value='Delete This user'></form>";

                    }
                    else
                    {
                    print "You did not select a user to delete";

                    }
                    print "</td></tr></table></p>";
                    print "</td></tr></table>";
                    print "</center>";
                    }
                    else
                    {
                    print "<table width='70%' border='0'>";
                    print "<tr class='headline'><td><center>Not logged in as Admin</td></tr>";
                    print "<tr class='forumrow'><td>";
                    print "You are not logged in as Administrator, please log in.";
                    print "<form method='POST' action='../authenticate.php'>";
                    print "Type Username Here: <input type='text' name='username' size='15'><br>";
                    print "Type Password Here: <input type='password' name='password' size='15'><br>";
                    print "<input type='submit' value='submit' name='submit'>";
                    print "</form>";
                    print "</td></tr></table>";
                    }

                    ?>

                    now this says Unknown table 'id' in MULTI DELETE as the sql error. i cant figure it out , oh how to you send scripts with the php colours on mine are plane text,

                    Comment


                      #11
                      I also have a problem when i search i do get the results i expect with a few unwanted entries that is when i search for user i expect to find
                      nick : gender : city
                      PHP Code:
                      <?php
                      require    'inc/head.inc';
                      require    
                      'inc/header.inc';
                              
                      require    
                      'inc/search.inc';
                          if(!empty(
                      $_POST['search']))
                          {
                              
                      $_SESSION['search']    =    mysql_real_escape_string(htmlentities(stripslashes($_POST['search'])));
                              
                      $sql    =    "SELECT nick, city, sex FROM users WHERE nick LIKE '%".$_SESSION['search']."%' OR fullname  LIKE '%".$_SESSION['search']."%' LIMIT 0, 10";
                              
                      $query    =    mysql_query($sql$con);
                          if((
                      $rows    =    mysql_num_rows($query) < 1) || empty($_SESSION['search']))
                              print    
                      'No one was found';
                          else
                          while(
                      $result    =    mysql_fetch_array($query))
                          {
                              print    
                      '<a href=user.php?nick='.$result['nick'].'>'.$result['nick'].'</a>';
                              if(!empty(
                      $result['sex']))
                                  print    
                      ' : '.$result['sex'];
                              if(!empty(
                      $result['city']))
                                  print    
                      ' : '.$result['city'];
                                  print    
                      '<br>';
                          }
                                                  
                          }
                          require    
                      'inc/foot.inc';
                      ?>
                      live page wapEvening if i search for "senzo" i get
                      nick : gender : city : 1
                      and if i search for "lee" i get
                      : 1
                      : 1 : 1 : 1 : 1 : 1
                      now i don't understand where these integer 1's comes from
                      libra.wen.ru

                      Comment


                        #12
                        change session to request
                        Visit: Chat4u.mobi - The New Lay Of being a site of your dreams!
                        Visit: WapMasterz Coming Back Soon!
                        _______
                        SCRIPTS FOR SALE BY SUBZERO
                        Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders.
                        FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others...
                        _______
                        Info & Tips
                        php.net
                        w3schools.com

                        Comment

                        Working...
                        X