Jump to content

Recommended Posts

Okay so thanks to only one for helping me with the last problem.

 

Now I have a drop down box, I select a user, hit approve and it updates their status in the database and SHOULD remove their name from the drop down box.

If I refresh the page a 2nd time after I click on the submit button, or if I approve another user, it will remove their name.

But it always takes 2 page refreshes to remove their name.

 

How can I make it so after I hit the approve button, their name is removed from the drop down list?

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/74349-solved-page-refresh/
Share on other sites

Here is the code

 

<form method="post" action="member.php">
<?
                echo "<select name=\"NickName\">";
                echo "<option size =30 selected>Select</option>";
             if(mysql_num_rows($approvalQuery))
             {
                while($myrow = mysql_fetch_assoc($approvalQuery))
             {
                echo "<option>$myrow[NickName]</option>";
             }
             }
             else {
                echo "<option>No Names Present</option>"; 
             }   
?>
          </td>
   </tr>
   </td>
   <td valign="top" align="left" class="control_panel_td_2">
         <input type="submit" value="Approve" name="Approve">
         <input type="submit" value="Deny" name="Deny">
         </form>
   </td>
<?
      }
?>
   </tr>   
<?
   //Approves user account activation
   if(isset($_POST['Approve']))
     {
    mysql_query("UPDATE Profiles SET Status = 'Active' WHERE Status='Approval' AND NickName = '{$_POST['NickName']}'") or die (mysql_error());
   }

Link to comment
https://forums.phpfreaks.com/topic/74349-solved-page-refresh/#findComment-375714
Share on other sites

You have not got a vaue for the option This ....

<option>$myrow[NickName]</option>;

 

should look like

<select name="NickName">;

<option value="1">$myrow[NickName]</option>;

// where value is the unigue ID in the database table.

 

then on the PHP (only) update table

UPDATE table SET Aproved = "Y" WHERE ID=1

 

 

Link to comment
https://forums.phpfreaks.com/topic/74349-solved-page-refresh/#findComment-375720
Share on other sites

You have not got a vaue for the option This ....

<option>$myrow[NickName]</option>;

 

Actually the indefinite value for an option is defined within itself.

 

So the value of <option>$myrow[Nickname]</option> is whatever $myrow[Nickname] is defined to.

Link to comment
https://forums.phpfreaks.com/topic/74349-solved-page-refresh/#findComment-375730
Share on other sites

There is code missing

<form method="post" action="member.php">  No </form>

as for

AND NickName = '{$_POST['NickName']}'")

 

$_POST['NickName'] YOU have not put any value to this. If this is working then you

have some invisible code

 

<OPTON Value="X">Name</Option>

 

without the X it can't work.

 

 

Link to comment
https://forums.phpfreaks.com/topic/74349-solved-page-refresh/#findComment-375736
Share on other sites

There is code missing

<form method="post" action="member.php">  No </form>

as for

AND NickName = '{$_POST['NickName']}'")

 

$_POST['NickName'] YOU have not put any value to this. If this is working then you

have some invisible code

 

<OPTON Value="X">Name</Option>

 

without the X it can't work.

 

 

 

Without the X it can work.

 

<option>x</option> the value of that is x

<option value="x">hello</option> the value of that is x

<option>Name</option> the value of that is Name

Link to comment
https://forums.phpfreaks.com/topic/74349-solved-page-refresh/#findComment-375760
Share on other sites

Two or more people can't have the same nickname.

You don't really need to know much more than this.

 

//Grabs users awaiting Approval from the database - FINDME

$approvalQuery = mysql_query("SELECT ID, NickName, Coach_Name, Email FROM `Profiles` WHERE Status='Approval' AND `Coach_Name`='{$p_arr['Coach_Name']}'");

 

$nameQuery = mysql_query("SELECT Coach_Name, NickName, Status FROM `Profiles` WHERE `ID`='{$p_arr['ID']}'");

$arrName = mysql_fetch_assoc( $nameQuery );

?>

</td>

</tr>

<?

if ($arrName["Coach_Name"] == $arrName["NickName"]){

?>

    <tr> 

  <td>Approvals: </td>

          <td>

<form method="post" action="member.php">

<?

                echo "<select name=\"NickName\">";

                echo "<option size =30 selected>Select</option>";

            if(mysql_num_rows($approvalQuery))

            {

                while($myrow = mysql_fetch_assoc($approvalQuery))

            {

                echo "<option>$myrow[NickName]</option>";

            }

            }

            else {

                echo "<option>No Names Present</option>";

            } 

?>

          </td>

  </tr>

  </td>

  <td valign="top" align="left" class="control_panel_td_2">

        <input type="submit" value="Approve" name="Approve">

        <input type="submit" value="Deny" name="Deny">

        </form>

  </td>

<?

      }

?>

  </tr> 

<?

  //Approves user account activation

  if(isset($_POST['Approve']))

    {

    mysql_query("UPDATE Profiles SET Status = 'Active' WHERE Status='Approval' AND NickName = '{$_POST['NickName']}'") or die (mysql_error());

  }

 

//Denies user account activation

if(isset($_POST['Deny']))

  {

    mysql_query("UPDATE Profiles SET Status = 'Rejected' WHERE Status='Approval' AND NickName = '{$approvalQuery['NickName']}'") or die (mysql_error());

}

Link to comment
https://forums.phpfreaks.com/topic/74349-solved-page-refresh/#findComment-375773
Share on other sites

Try this

 

<?php

//Grabs users awaiting Approval from the database - FINDME
$approvalQuery = mysql_query("SELECT ID, NickName, Coach_Name, Email FROM `Profiles` WHERE Status='Approval' AND `Coach_Name`='{$p_arr['Coach_Name']}'");

$nameQuery = mysql_query("SELECT Coach_Name, NickName, Status FROM `Profiles` WHERE `ID`='{$p_arr['ID']}'");
$arrName = mysql_fetch_assoc($nameQuery );

//Approves user account activation
if (isset($_POST['Approve'])) {
    mysql_query("UPDATE Profiles SET Status = 'Active' WHERE Status='Approval' AND NickName = '{$_POST['NickName']}'") or die(mysql_error());
}

//Denies user account activation
if (isset($_POST['Deny'])) {
    mysql_query("UPDATE Profiles SET Status = 'Rejected' WHERE Status='Approval' AND NickName = '{$approvalQuery['NickName']}'") or die(mysql_error());
}

?>
</td>
</tr>
<?
if ($arrName["Coach_Name"] == $arrName["NickName"]) {
    ?>
    <tr>
    <td>Approvals: </td>
    <td>
    <form method="post" action="member.php">
    <?
    echo "<select name=\"NickName\">";
    echo "<option size =30 selected>Select</option>";
    if (mysql_num_rows($approvalQuery)) {
        while ($myrow = mysql_fetch_assoc($approvalQuery)) {
            echo "<option>$myrow[NickName]</option>";
        }
    } else {
        echo "<option>No Names Present</option>";
    }
    ?>
    </td>
    </tr>
    </td>
    <td valign="top" align="left" class="control_panel_td_2">
    <input type="submit" value="Approve" name="Approve">
    <input type="submit" value="Deny" name="Deny">
    </form>
    </td>
    <?
}
?>
</tr>

Link to comment
https://forums.phpfreaks.com/topic/74349-solved-page-refresh/#findComment-375810
Share on other sites

Oops, try this

 

<?php

//Approves user account activation
if (isset($_POST['Approve'])) {
    mysql_query("UPDATE Profiles SET Status = 'Active' WHERE Status='Approval' AND NickName = '{$_POST['NickName']}'") or die(mysql_error());
}

//Denies user account activation
if (isset($_POST['Deny'])) {
    mysql_query("UPDATE Profiles SET Status = 'Rejected' WHERE Status='Approval' AND NickName = '{$approvalQuery['NickName']}'") or die(mysql_error());
}

//Grabs users awaiting Approval from the database - FINDME
$approvalQuery = mysql_query("SELECT ID, NickName, Coach_Name, Email FROM `Profiles` WHERE Status='Approval' AND `Coach_Name`='{$p_arr['Coach_Name']}'");

$nameQuery = mysql_query("SELECT Coach_Name, NickName, Status FROM `Profiles` WHERE `ID`='{$p_arr['ID']}'");
$arrName = mysql_fetch_assoc($nameQuery );

?>
</td>
</tr>
<?
if ($arrName["Coach_Name"] == $arrName["NickName"]) {
    ?>
    <tr>
    <td>Approvals: </td>
    <td>
    <form method="post" action="member.php">
    <?
    echo "<select name=\"NickName\">";
    echo "<option size =30 selected>Select</option>";
    if (mysql_num_rows($approvalQuery)) {
        while ($myrow = mysql_fetch_assoc($approvalQuery)) {
            echo "<option>$myrow[NickName]</option>";
        }
    } else {
        echo "<option>No Names Present</option>";
    }
    ?>
    </td>
    </tr>
    </td>
    <td valign="top" align="left" class="control_panel_td_2">
    <input type="submit" value="Approve" name="Approve">
    <input type="submit" value="Deny" name="Deny">
    </form>
    </td>
    <?
}
?>
</tr>

Link to comment
https://forums.phpfreaks.com/topic/74349-solved-page-refresh/#findComment-376337
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.