Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7775423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:37:40+00:00 2026-06-01T17:37:40+00:00

so this was working perfect up until an hour ago and since then i

  • 0

so this was working perfect up until an hour ago and since then i have racked my brain to fix it and got nothing, maybe im missing the obvious (thats usually the case).

The code prints out a list of users and a button to ban them in a table, however the problem is if you click ban on say.. the 34th user it bans the first, then if you click ban on the 56th user it bans the second user. If you see my code you should see that that shouldn’t be the case (note all other details are perfectly right except for the uID):

  $query = mysql_query("SELECT id, full_name, banned, username from `tblUsers`");
        while($row = mysql_fetch_array($query)){
            $uID = $row['id'];
            if($row['banned'] == '0'){ 
                $banBool =  '<form id="ban" method="post" action="ban.php?uid='.$uID.'">
            <input type="hidden" name="ban" value="" /> 
            <a onclick="document.getElementById(\'ban\').submit();">Ban</a>
        </form>'; }else{   
            $banBool = '<form id="unban" method="post" action="unban.php?uid='.$uID.'">
            <input type="hidden" name="name" value="" /> 
            <a onclick="document.getElementById(\'unban\').submit();">UnBan</a>
            </form>' ;
        }
            if($row['banned'] == '1'){
                $status = 'Banned';
            }else{
                $status = 'Active';
            }
            echo "<tr><td>" . $row['username'] . " " . $uID . "</td><td>" . $banBool . "</td><td>" . $status . "</td><td>" . $row['full_name'] . "</td></tr>";
        }

The issue is in the action=”unban.php?uid=’.$uID.’ as when i trace the path the id is always the lowest number (top result)

ban.php

<?php
include '../../includes/dataBase.class.php';
sql::connect();
if(!sql::checkAdmin() == 1){
    header("Location: ../myaccount.php");
}
if(!isset($_GET['uid'])){
    header("Location: users.php?action=1");
}
$uid = $_GET['uid'];
$ip = $_SERVER['REMOTE_ADDR'];  
mysql_query("INSERT INTO `uipBan` (`ip`) VALUES ('$ip')")or die(mysql_error()); 
mysql_query("UPDATE tblUsers SET banned = '1' WHERE id = '$uid'")or die(mysql_error());
//header("Location: users.php?action=1");
echo $uid;
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T17:37:41+00:00Added an answer on June 1, 2026 at 5:37 pm

    You provide a form for each user which bans/unbans that user. The problem is in your form id because they’re not unique. When you click on any Ban/UnBan link, JavaScript searches for the ban/unban element, finds the first one and submits that one.

    The solution is very easy:

      $query = mysql_query("SELECT id, full_name, banned, username from `tblUsers`");
            while($row = mysql_fetch_array($query)){
                $uID = $row['id'];
                if($row['banned'] == '0'){ 
                    $banBool =  '<form id="ban' . $uID . '" method="post" action="ban.php?uid='.$uID.'">
                <input type="hidden" name="ban" value="" /> 
                <a onclick="document.getElementById(\'ban' . $uID . '\').submit();">Ban</a>
            </form>'; }else{   
                $banBool = '<form id="unban' . $uID . '" method="post" action="unban.php?uid='.$uID.'">
                <input type="hidden" name="unban" value="" /> 
                <a onclick="document.getElementById(\'unban' . $uID . '\').submit();">UnBan</a>
                </form>' ;
            }
                if($row['banned'] == '1'){
                    $status = 'Banned';
                }else{
                    $status = 'Active';
                }
                echo "<tr><td>" . $row['username'] . " " . $uID . "</td><td>" . $banBool . "</td><td>" . $status . "</td><td>" . $row['full_name'] . "</td></tr>";
            }
    

    I just included the User ID on every form and JS call so that they are unique. (Also, your second hidden field had the name as name)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this tabs that are working perfect in any browser apart from IE
I have this code for polyline which is working perfect. How do i add
This seems to make perfect sense, but it is not working. I seem to
Update: Got this working by disabling CodeIgniter Profiler which was interfering with the Ajax
I have this (working) CPU code: #define NF 3 int ND; typedef double (*POT)(double
I have this working: address = [] for row in ws.iter_rows(row_offset=4,column_offset=3): if len(row) >
I have this working query that outputs URL and click counts from database. <?php
Has anyone got this working in a web application? No matter what I do
We have been using XMLRPC for android and it was working well until we
losing sleep over this issue My app hierarchy is ListVC1-->ListVC2-->DetailVC. [Working perfect] and... SearchListVC-->DetailVC

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.