0

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>

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>

And still this seems as if its doesn't work at all because the div will always be shown even if I put nonen 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.

2
Contributors
2
Replies
8
Views
1 Week
Discussion Span
Last Post by Mr.M
1

In first version you are missing the other condition ($_SESSION['iiio'] != "pending"). In that case the div is shown by default.

It looks like you are using Bootstrap so you can use the show and hidden classes provided by Bootstrap. I am using ternary expression here since it is most convenient:

<div class="<?php echo $_SESSION['iiio'] == "pending" ? 'show' : 'hidden';?>"
<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>

If you are not using Bootstrap then create the two classes yourself:

.show {
    display: block;
}

.hidden {
    display: none;
}
Votes + Comments
Perfect
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.