用于更新数据的按钮

I have a list of buttons that each pass on a different value. The code should store this value as a variable or session, which then is passed on to a function that updates the table row of the value. I tried just storing this value as a variable and then passing it on, but that didn't work so I figured I'd make it into a session. And that didn't work either, no idea where to go from here.

Here's a button example:

<tr>
  <td data-title="Name"><a href="#"><img src="banner.jpg" width="400"></a></td>
  <td data-title="Link">
    <form name="first" action="pending.php" method="POST"><input type="hidden" name="xz" value="one"><a class="mbutton" onclick="document.forms['first'].submit();">Gedaan</a></form>
  </td>
  <td data-title="Status"><p class="ptable"><?= $fgmembersite->One(); ?></p></td>
</tr>

Here's where the form leads to:

<?PHP
include("./include/membersite_config.php");
$_SESSION['postdata'] = $_POST;
$bname = $_SESSION['postdata'];
if($fgmembersite->Pending($bname))
{
    $fgmembersite->RedirectToURL("index.php");
}


?>

So this should pass on $bname to the function Pending().

And here's pending:

function Pending($bname)
    {
        if(!$this->DBLogin())
        {
            $this->HandleError("Database login failed!");
            return false;
        }   

        $result = mysql_query("Select * from $this->tablename where confirmcode='y'",$this->connection);   
        if(!$result || mysql_num_rows($result) <= 0)
        {
            $this->HandleError("Error");
            return false;
        }
        $row = mysql_fetch_assoc($result);
        $ux = $row['username'];
        $ustat = $row['one'];
        $bname = $_SESSION['postdata']['xz'];

        $qry = "Update $this->tablename Set $bname='In behandeling' Where  username='$ux'";

        if(!mysql_query( $qry ,$this->connection))
        {
            $this->HandleDBError("Error inserting data to the table
query:$qry");
            return false;
        }      
        return true;
    }

So you are saying that the Pending function is returning TRUE, and redirecting you to membership.php ? or index.php ( or are these the same ) -

  • if that query fails and returns false - you would just end up on the page that you had posted to .