Display and hide div based on if statement

Hi Guys. I'm having a serious problem that is holding me back. I have a file which is a user dashboard and this file gets data from another php script file which is called by a user login screen when a user clicks login. The file verify the credentials then if correct that its start to pull some data from the database. The problem is that now there are some users who don't complete their registration process which some stop where they need to make their payments so their accounts are kept with a status of pending which indicate that the user has not pay the registration fee. Now I am able to read the status from the database and assign it to the session so that I will work with on the dashboard, this controls which tells if the complete your registration button should be shown or not of which in this case because the status is pending the dashboard should show this button. My problem is showing or hiding it as this should be hidden when a user has paid his/her registration fee because this update the database with Active status.

I've tried this:
<div if($_SESSION['iiio'] == "pending"){echo " style='display: block';"};><a href="https://www.paymentgateway.com" ><button align="right" id="completeReg" name="completeReg"  class="btn btn-danger my-cart-btn my-cart-b" >Complete RegistrationComplete Registration</button></a></div>

Open in new window


But the above will just do what the `display:xxxx` has if it has `none` it won't display the block even if the condition is not met for this where it should display because the condition is no met and if I had `block` it will keep displaying the even if the condition is not met. I've also tried adding the `else` but still.

I've also tried JavaScript:
<script type="text/javascript">

     var xadminFee = '<%= Session["iiio"] %>';
     if(xadminFee == "pending"){
        
         document.getElementById("completeReg").style.display = "block"; // This is for displaying the complete registration process.
     }else{
        document.getElementById("completeReg").style.display = "none";
}

  </script>

Open in new window


And still this seems as if its doesn't work at all because the div will always be shown even if I put `none`n but still.

Remember the session is from a php file which contains the exact status from the database.

Anyone who can help me solve this problem.
LVL 2
Mlungisi NdlelaFounder of MCSIDevelopers also a software developerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Chris StanyonWebDevCommented:
Just wrap your entire button inside a PHP if statement:

<?php if($_SESSION['iiio'] == "pending"): ?>

<div>
    <a href="https://www.paymentgateway.com">
        <button align="right" id="completeReg" name="completeReg" class="btn btn-danger my-cart-btn my-cart-b" >Complete Registration</button>
    </a>
</div>

<?php endif; ?>

Open in new window

Now that block will only be rendered if iiio is 'pending'
1
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
HTML

From novice to tech pro — start learning today.