Display input depending on login - PHP

Asked

Viewed 73 times

0

Good afternoon, I have a form with some inputs, want to display only 1 input each login when logged in to the system, I thought to use IF and ELSE, but I can’t use it, someone can help me?

I’m trying like this:

    <?php

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

    if($cont['login'] == "educacao.fisica"){

    echo'

    <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 >'; 

    }else{ }

    </div> ?>

Continues to display all logins...

EDIT : I think I’m in the way, where I’m going wrong???

<?php 
$login = $_SESSION['login'];
$senha = $_SESSION['senha'];
$sql = "SELECT * FROM login WHERE login ='$login' AND senha = '$senha'";
$resultado = mysqli_query($link, $sql);
while ($cont = mysqli_fetch_array($resultado)) 
{  $class = $cont['class'];}

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


   if ($class == "adm") 
    {

echo '

      <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>

        ';
  }
?>  
  • What’s in $cont ?

  • You are there @Pedrohenrique.

  • https://www.php.net/manual/en/control-structures.switch.php Please provide more details on the inputs and outputs you are waiting for in your algorithm.

  • Hello, you could not create a column in login as for example the name "permission" and type INT and set the logins by permission numbers, so in the database search return this permission number and then show the login desired.

  • Samuel, lay out the schematics of the tables involved plus a sample of data. Without knowing these tables I can not help you with certainty, I can even give an answer but it would be a kick.

  • @Augustovasques That helps?

Show 1 more comment
No answers

Browser other questions tagged

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