put a div inside a function in php

Asked

Viewed 263 times

-1

I have this command that checks the database and checks if the user is locked, in case it shows an error message, if it is not locked it continues the normal execution. What I’m wanting is when it checks change the error message to a box, that when the user clicks the login button and if it is locked will appear this box.

Follow the code of the "box":

<div id="mod-danger" tabindex="-1" role="dialog" class="modal fade">
                <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                    <button type="button" data-dismiss="modal" aria-hidden="true" class="close"><span class="mdi mdi-close"></span></button>
                    </div>
                    <div class="modal-body">
                    <div class="text-center">
                        <div class="text-danger"><span class="modal-main-icon mdi mdi-close-circle-o"></span></div>
                        <h3>Atenção!</h3>
                        <p><h1>Usuario Bloqueado</h1><br><h2>PorFavor contatar algum adm para resolver.</h2></p>
                        <div class="xs-mt-50">
                        </div>
                    </div>
                    </div>
                    <div class="modal-footer"></div>
                </div>
                </div>

</div>

and I want to put that div in that function where it checks the lock

public function bloqueado(){
    $model = self::findByUsuLogin($this->usu_login);


    if ($model->usu_block){
         $this->addError('usu_login', "Usuario Bloqueado, por favor entrar em contato com algum adm.");
        return false;
    }else{
        return true;
    }
}

want to change the error mensg that appears that is inserir a descrição da imagem aqui to that screen with the error mensg inserir a descrição da imagem aqui

If anyone can help me I’d be grateful.

  • Sorry friend, I did not understand your question very well, can you explain a little better??? thanks.

  • you said to make echo to appear this box in case I want that box I put in the example and the first code just put it in echo would be this?

  • Oops, I read your comment and that’s right, because once the function is called it will call the modal and show as it wants.

  • Uai, exchange message line by $("#mod-danger").modal('show');

  • Mark the answer as accepted, see https://i.stack.Imgur.com/jx7Ts.png and because https://pt.meta.stackoverflow.com/questions/1078/como-e-por-que-aceitar-uma-resposta/1079#1079

1 answer

0

As there are not enough elements to reproduce your code, I did so with a simple conditional to show the error message screen

    $model="bloqueado";
    
    if ($model=="bloqueado"){
         $("#mod-danger").modal('show');
        //return false;
    }else{
        //return true;
    }
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

<div id="mod-danger" tabindex="-1" role="dialog" class="modal fade">
   <div class="modal-dialog">
     <div class="modal-content">
        <div class="modal-header">
           <button type="button" data-dismiss="modal" aria-hidden="true" class="close"><span class="mdi mdi-close"></span></button>
        </div>
        <div class="modal-body">
            <div class="text-center">
                <div class="text-danger"><span class="modal-main-icon mdi mdi-close-circle-o"></span></div>
                <h3>Atenção!</h3>
                <p><h1>Usuario Bloqueado</h1><br><h2>PorFavor contatar algum adm para resolver.</h2></p>
                <div class="xs-mt-50"></div>
            </div>
        </div>
        <div class="modal-footer"></div>
    </div>
</div>
</div>

  • it worked out vlw brother

Browser other questions tagged

You are not signed in. Login or sign up in order to post.