Display input depending on the value in the database?

Asked

Viewed 39 times

-1

Good guys, I have a form uploads, where there are 6 input file.

In my bank, I have a table called login where there are several different logins, it is possible for me to only display one input file if the user is logged in to an X login?

Example: If the user is logged in to the "nursing" login, only display the nursing input file...

I thought I’d use IF and ELSE, but I don’t know how in this situation... Somebody give me a little help plss Exemplo

My login file (.php security)

<?php  
session_start();
if((!isset ($_SESSION['login']) == true) and (!isset ($_SESSION['senha']) == true))
{
  unset($_SESSION['login']);
  unset($_SESSION['senha']);
  header('location:login.php');
  }

$logado = $_SESSION['login'];
?>

EDIT: My form:

<?php 
$codigo_relatorio = $_GET['codigo_relatorio'];
$sql = mysqli_query($link, "SELECT * FROM relatorio WHERE codigo_relatorio = '$codigo_relatorio' ");
while ($cont = mysqli_fetch_array($sql)) {
?>


                                             <div class="form-group">
                                                    <label for="file-multiple-input" class=" form-control-label"> <b>Educação Física - Arquivo:</b></b></label>
                                                     <a style='color: Blue' href="uploads/uploadsed/<?php echo $cont['relatorio_educacao_fisica'];?>"><?php echo $cont['relatorio_educacao_fisica'];?></a>

                                                    <input type="file" id="file-multiple-input" name="fileed" multiple="" class="form-control-file" >

                                            </div>
                                            <br>
                                            <div class="form-group">
                                                    <label for="file-multiple-input" class=" form-control-label"> <b>Enfermagem - Arquivo:</b></label>
                                                     <a style='color: Blue' href="uploads/uploadsenf/<?php echo $cont['relatorio_enfermagem'];?>"><?php echo $cont['relatorio_enfermagem'];?></a>
                                                    <input type="file" id="file-multiple-input" name="file" multiple="" class="form-control-file">

                                            </div>
                                            <br>


                                              <div class="form-group">
                                                    <label for="file-multiple-input" class=" form-control-label"> <b>Nutrição - Arquivo:</b></label>
                                                     <a style='color: Blue' href="uploads/uploadsnut/<?php echo $cont['relatorio_nutricao'];?>"><?php echo $cont['relatorio_nutricao'];?></a>
                                                    <input type="file" id="file-multiple-input" name="filenut" multiple="" class="form-control-file" >

                                            </div>

                                        <br>

                                             <div class="form-group">
                                                    <label for="file-multiple-input" class=" form-control-label"> <b>Artesanato - Arquivo:</b></label>
                                                     <a style='color: Blue' href="uploads/uploadsart/<?php echo $cont['relatorio_artesanato'];?>"><?php echo $cont['relatorio_artesanato'];?></a>
                                                    <input type="file" id="file-multiple-input" name="fileart" multiple="" class="form-control-file">

                                            </div>    
                                           <br>
                                              <div class="form-group">
                                                    <label for="file-multiple-input" class=" form-control-label"> <b>Terapia Ocupacional - Arquivo:</b></label>
                                                     <a style='color: Blue' href="uploads/uploadster/<?php echo $cont['relatorio_terapia_ocupacional'];?>"><?php echo $cont['relatorio_terapia_ocupacional'];?></a>
                                                    <input type="file" id="file-multiple-input" name="fileter" multiple="" class="form-control-file" >

                                            </div>
                                            <br>
                                            <div class="form-group">
                                                    <label for="file-multiple-input" class=" form-control-label"> <b>Serviços sociais - Arquivo:</b></label>
                                                     <a style='color: Blue' href="uploads/uploadser/<?php echo $cont['relatorio_servicos_sociais'];?>"><?php echo $cont['relatorio_servicos_sociais'];}}?></a>
                                                    <input type="file" id="file-multiple-input" name="fileser" multiple="" class="form-control-file" >

                                            </div>
                                            </div>   
  • Welcome to Sopt. Please add any code that is relevant for someone to analyze the problem and help them solve it. With only this image is impossible.

  • first go to the database and return the login location and make an if, for example if ($local = "enfermagem") { <input .....}

  • Code this form to help answer.

  • I put the form...

1 answer

0

Let’s go there, first, just you save the logged user information in a SESSION variable, for example:

$tipo = $_SESSION["tipo"];

Then just pick and variable and put in the if of the fields, example:

if($tipo=="enfermagem"){


}

Browser other questions tagged

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