Fill out information from the database search form by Codusuario and Codficha

Asked

Viewed 51 times

0

I’m trying to fill information in the form searching the database by codusuario and codficha, but there is an error and do not know how to solve, follow my code below:

Code of the movement screen where I click on view & edit, when I click on this button it should fill the screen that opens to edit the form.

inserir a descrição da imagem aqui

Code of the page above

movementMusica.php

 <?php
session_start();
$connect = mysqli_connect('localhost', 'root', '') or die('Erro ao conectar ao banco de dados');
$db = mysqli_select_db($connect, 'db_uberlandia');

// A sessão precisa ser iniciada em cada página diferente
if (!isset($_SESSION))
session_start();

// Verifica se não há a variável da sessão que identifica o usuário
if (!isset($_SESSION['UsuarioID'])) {
// Destrói a sessão por segurança
session_destroy();
// Redireciona o visitante de volta pro login
header("Location: index.php");
exit;
}

$codUsuario = $_SESSION['UsuarioID'];
?>
<!DOCTYPE html>
<html lang="pt-br">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="Página Administrativa">
    <meta name="author" content="Cesar">
    <link rel="icon" href="imagens/favicon.ico">
    
    <title>Movimentação Musica</title>
    <link href="src/css/bootstrap.min.css" rel="stylesheet">
    <link href="src/css/bootstrap-theme.min.css" rel="stylesheet">
    <link href="src/css/theme.css" rel="stylesheet">
    <script src="src/js/ie-emulation-modes-warning.js"></script>

    <!--adicionado depois-->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css">
    <link rel="stylesheet" href="src/css/modificadonovo.css">
    <!--script adicionado depois-->
</head>

<body role="document">
    <div id="responsive-admin-menu">
        <div id="responsive-menu">
            <div class="menuicon">≡</div>
        </div>

        <div id="logo"></div>
        <!--Menu-->
        <div id="menu">
            <a href="menuMusica.php"><button type='button' class='btn btn-md btn-info'>Voltar</button></a>
        </div>
        <!--Menu-->
        
        </br>
    </div>
    <div class="h1">
        <center>
            <h2>Movimentações Ficha Cadastral Musica</h2>
        </center>
    </div>
    <?php
    $result_usuario = "SELECT * FROM ficha_Cadastral_Musica where (`CodUsuario` = '" . $codUsuario . "')";
    $resultado_usuario = mysqli_query($connect, $result_usuario);
    ?>	
    <div class="container theme-showcase" role="main">      
        <div class="page-header">
            <h1>Lista de Fichas Inseridas no Sistema</h1>
        </div>
        <div class="row">
            <div class="col-md-12">
                <table class="table" >
                    <thead>
                        <tr>
                            <th>CODIGO FICHA</th>
                            <th>IEQ BAIRRO</th>
                            <th>PASTOR</th>
                            <th>LIDER</th>
                            <th>Ações</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php
                        while ($row_usuario = mysqli_fetch_assoc($resultado_usuario)) {
                            echo "<tr>";
                            echo "<td>" . $row_usuario['codFichaMusica'] . "</td>";
                            echo "<td>" . $row_usuario['ieqbairro'] . "</td>";
                            echo "<td>" . $row_usuario['pastor'] . "</td>";
                            echo "<td>" . $row_usuario['lider'] . "</td>";
                            "</td>";
                            ?>
                        <td>
                            <a href='editarFichaCadastralMusica.php?CodUsuario=<?php echo $row_usuario['CodUsuario'] ?><?php $row_usuario['CodUsuario']; ?>?codFicha=<?php echo $row_usuario['codFichaMusica'] ?><?php $row_usuario['codFichaMusica']; ?>?'>
                                <button type='button'  class='btn btn-sm btn-warning'>Visualizar & Editar</button></a>

                            <a href='excluirFichaCadastralMusica.php?CodUsuario=<?php echo $row_usuario['CodUsuario'] ?><?php $row_usuario['CodUsuario']; ?>'>
                                <button type='button' class='btn btn-sm btn-danger'>Excluir</button></a>
                        <?php
                            echo "</tr>";
                         }?>
                    </tbody>
                </table>
            </div>
        </div>
    </div> <!-- /container -->

    <!-- Bootstrap core JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script src="js/jquery.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <script src="js/docs.min.js"></script>
    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
    <script src="js/ie10-viewport-bug-workaround.js"></script>
</body>
</html>

This is the page to edit the form see that the following error occurs.

inserir a descrição da imagem aqui

Follow the Cogido page above

editarFichaCadastralMusica.php

<?php
$connect = mysqli_connect('localhost', 'root', '');
$db = mysqli_select_db($connect, 'db_uberlandia');

$gid = $_GET['CodUsuario'];
$codFicha = $_GET['codFichaMusica'];
$q = ("SELECT * FROM ficha_Cadastral_Musica WHERE CodUsuario='" . $gid . "' AND codFichaMusica ='" . $codFicha . "'");

$resultado_usuario = mysqli_query($connect, $q);
$row_usuario = mysqli_fetch_assoc($resultado_usuario);
?>

<!DOCTYPE html>
<html lang="en" >
<head>
    <meta charset="UTF-8">
    <title>Editar Ficha Cadastral Musica</title>
    <link rel='stylesheet' href='https://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css'>
    <link rel="stylesheet" href="src/css/style1.css">
    <link rel="stylesheet" href="src/css/modificado.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <link rel='stylesheet prefetch' href='https://fonts.googleapis.com/css?family=Roboto:400,100,300,500,700,900'>
    <link rel='stylesheet prefetch' href='https://fonts.googleapis.com/css?family=Montserrat:400,700'>
    <link rel='stylesheet prefetch' href='https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css'>
    <style>
        label {
            display: block;
            color: #0e0572;
        }
        ::placeholder ,select, option { /* Chrome, Firefox, Opera, Safari 10.1+ */
            color: #0e0572;
            font-weight: bold;

        }
        ::form-group  { /* Chrome, Firefox, Opera, Safari 10.1+ */
            color: #0e0572;
            font-weight: bold;

        }
        .floatBlock {
            margin: 0 1.81em 0 0;
        }
        .labelish {
            color:#0e0572;
            margin: 0;
            font-weight: bold;
        }
        .paymentOptions {
            border: none;
            display: flex;
            flex-direction: row;
            justify-content: flex-start;
            break-before: always;
            margin: 0 0 3em 0;
        }
        #purchaseOrder {
            margin: 0 0 2em 0;
        }
        #nomeministeriocarreira{
            height: 135px;
        }
    </style>

    <script>
        function mascara(t, mask) {
            var i = t.value.length;
            var saida = mask.substring(1, 0);
            var texto = mask.substring(i)
            if (texto.substring(0, 1) != saida) {
                t.value += texto.substring(0, 1);
            }
        }
    </script>
</head>

<body>
    <div id="responsive-admin-menu">
        <div id="responsive-menu">
            <div class="menuicon">≡</div>
        </div>

        <div id="logo"></div>

        <!--Menu-->
        <div id="menu">
            <a href="menuMusica.php" title=""><i class="icon-dashboard"></i><span>Home</span></a>
            <a href="fichaCadastralMusica.html" title="Pages"><i class="icon-fixed-width icon-pencil"></i><span> Ficha Cadastral</span></a>
            <a href="relatoriomensal1regiaomusica.html" title="Pages"><i class="icon-file-alt"></i><span> Relatório Mensal</span></a>
            <a href="movimentacoesMusica.php" title="Pages"><i class="icon-fixed-width icon-book"></i><span> Movimentações Ficha &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Cadastral</span></a>
            <a href="movimentacoes1regiaomusicarelatorio.php" title="Pages"><i class="icon-fixed-width icon-book"></i><span> Movimentações &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Relatório</span></a>
            <a href="logout.php" title="Pages"><i class="icon-fixed-width icon-cogs"></i><span> Sair</span></a>
        </div>
        <!--Menu-->
    </div>

    <div id="content-wrapper">
        <form method="POST" action="alteracaoFichaCadastralMusica.php">
            <center>
                <h1>Editar Ficha Cadastral Musica</h1>
            </center>

            <div class="contentform">
                <div id="sendmessage"> Your message has been sent successfully. Thank you. </div>

                <input type="hidden" name="CodUsuario" value="<?php echo $row_usuario['CodUsuario']; ?>">
                <input type="hidden" name="codFichaMusica" value="<?php echo $row_usuario['codFichaMusica']; ?>">

                <div class="form-group">
                    <p class="labelish">I.E.Q Bairro:</p>
                    <span class="icon-case"><i class="fa fa-bars custom"></i></span>
                    <font color="#6b0202"><input type="text"  name="ieqbairro" id="ieqbairro"  data-rule="required" style="text-transform: uppercase;"  placeholder="Não há registro no banco" value="<?php echo $row_usuario['ieqbairro']; ?>"></font>
                </div>

                <div class="form-group">
                    <p class="labelish">Pastor:</p>
                    <span class="icon-case"><i class="fa fa-bars custom"></i></span>
                    <input type="text" name="pastor" id="pastor" data-rule="required"  style="text-transform: uppercase;" placeholder="Não há registro no banco" value="<?php echo $row_usuario['pastor']; ?>">
                </div>


                <div class="form-group">
                    <p class="labelish">Líder:</p>
                    <span class="icon-case"><i class="fa fa-bars custom"></i></span>
                    <input type="text" name="lider" id="lider" style="text-transform: uppercase;" data-rule="required" placeholder="Não há registro no banco" value="<?php echo $row_usuario['lider']; ?>">
                </div>

                <div class="form-group">
                    <p class="labelish">Células Ativas:</p>
                    <span class="icon-case"><i class="fa fa-bars custom"></i></span>
                    <input type="text" name="celulasativas" id="celulasativas" style="text-transform: uppercase;" data-rule="required"placeholder="Não há registro no banco" value="<?php echo $row_usuario['celulaAtivas']; ?>">

                </div> 

                <div class="form-group">
                    <p class="labelish">Participantes Celulas Quantidade:</p>
                    <span class="icon-case"><i class="fa fa-bars custom"></i></span>
                    <input type="number" name="participantescelulas" id="participantescelulas"  data-rule="required" style="text-transform: uppercase;" placeholder="Não há registro no banco" value="<?php echo $row_usuario['participantescelulas']; ?>">
                </div> 

                <div class="form-group">
                    <p class="labelish">Quantidade Reuniões:</p>
                    <span class="icon-case"><i class="fa fa-bars custom"></i></span>
                    <input type="number" name="quantidadereunioes" id="quantidadereunioes" data-rule="required" style="text-transform: uppercase;"  placeholder="Não há registro no banco" value="<?php echo $row_usuario['quantidadereunioes']; ?>">
                </div> 

                <div class="form-group">
                    <p class="labelish">Quantidade Ensaios Mensais:</p>
                    <span class="icon-case"><i class="fa fa-bars custom"></i></span>
                    <input type="number" name="quantidaensamensal" id="quantidaensamensal" data-rule="required"  style="text-transform: uppercase;" placeholder="Não há registro no banco" value="<?php echo $row_usuario['quantidaensamensal']; ?>">
                </div>

                <div class="form-group">
                    <p class="labelish">Dia do Ensaio:</p>
                    <!-- <span class="icon-case"><i class="fa fa-bookmark custom"></i></span>-->
                    <!--<input type="text" name="diaensaio" id="diaensaio" style="text-transform: uppercase;"  placeholder="Dia do Ensaio"/>-->
                    <select class="form-control" name="diaensaio" id="diaensaio">
                        <option><?php echo $row_usuario['diaensaio']; ?></option>
                        <option>SEGUNDA</option>
                        <option>TERÇA</option>
                        <option>QUARTA</option>
                        <option>QUINTA</option>
                        <option>SEXTA</option>
                        <option>SABADO</option>
                        <option>DOMINGO</option>
                    </select>
                </div> 		

                <div class="form-group">
                    <p class="labelish">Hora do Ensaio:</p>
                    <span class="icon-case"><i class="fa fa-bars custom"></i></span>
                    <input type="text" name="horaensaio" id="horaensaio" onkeypress="mascara(this, '--:--')" maxlength="5" style="text-transform: uppercase;"  placeholder="Não há registro no banco" value="<?php echo $row_usuario['horaensaio']; ?>">
                </div> 		 

                <div class="form-group">
                    <p class="labelish">Total de Membros do Departamento:</p>
                    <span class="icon-case"><i class="fa fa-bars custom"></i></span>
                    <input type="number" name="totalmembrosdepartamento" id="totalmembrosdepartamento"  placeholder="Não há registro no banco" style="text-transform: uppercase;"  value="<?php echo $row_usuario['totalmenbrosminis']; ?>">
                </div>

                <div class="form-group">
                    <p class="labelish">Vocal:(qtos):</p>
                    <span class="icon-case"><i class="fa fa-bars custom"></i></span>
                    <input type="number" name="vocal" id="vocal" data-rule="required" style="text-transform: uppercase;"  pplaceholder="Não há registro no banco" value="<?php echo $row_usuario['vocalquant']; ?>">
                </div>
                
                <div class="form-group">
                    <p class="labelish">Mulheres: Contralto(qtas):</p>
                    <span class="icon-case"><i class="fa fa-bars custom"></i></span>
                    <input type="number" name="mulhercontralto" id="mulhercontralto" data-rule="required" onkeypress="mascaraData(this)" style="text-transform: uppercase;" placeholder="Não há registro no banco"
                           value="<?php echo $row_usuario['mulhercontralto']; ?>">
                </div>

                <div class="form-group">
                    <p class="labelish">Mezzo-soprano(qtas):</p>
                    <span class="icon-case"><i class="fa fa-bars custom"></i></span>
                    <input type="number" name="mezzosoprano" id="mezzosoprano"  data-rule="required" style="text-transform: uppercase;" placeholder="Não há registro no banco" value="<?php echo $row_usuario['mulhermezzosoprano']; ?>">
                </div>

                <div class="form-group">
                    <p class="labelish">Soprano(qtas):</p>
                    <span class="icon-case"><i class="fa fa-bars custom"></i></span>
                    <input type="number" name="soprano" id="soprano" data-rule="required" style="text-transform: uppercase;" placeholder="Não há registro no banco" value="<?php echo $row_usuario['mulhersoprano']; ?>">
                </div>

                <div class="form-group">
                    <p class="labelish">Homens: Baixo(qtos):</p>
                    <span class="icon-case"><i class="fa fa-bars custom"></i></span>
                    <input type="number" name="homensbaixo" id="homensbaixo" data-rule="required" style="text-transform: uppercase;"  placeholder="Não há registro no banco" value="<?php echo $row_usuario['homensbaixo']; ?>">
                </div>

                <div class="form-group">
                    <p class="labelish">Barítono(qtos):</p>
                    <span class="icon-case"><i class="fa fa-bars custom"></i></span>
                    <input type="number" name="baritono" id="baritono" data-rule="required" style="text-transform: uppercase;" placeholder="Não há registro no banco" value="<?php echo $row_usuario['homensbaritono']; ?>">
                </div>

                <div class="form-group">
                    <p class="labelish">Tenor(qtos):</p>
                    <span class="icon-case"><i class="fa fa-bars custom"></i></span>
                    <input type="number" name="tenor" id="tenor" data-rule="required" style="text-transform: uppercase;" placeholder="Não há registro no banco" value="<?php echo $row_usuario['homenstenor']; ?>">
                </div>

                <div class="form-group">
                    <p class="labelish">Guitarrista:(qtos):</p>
                    <span class="icon-case"><i class="fa fa-bars custom"></i></span>
                    <input type="number" name="guitarrista" id="guitarrista" data-rule="required" style="text-transform: uppercase;"  placeholder="Não há registro no banco" value="<?php echo $row_usuario['guitarraqtd']; ?>">
                </div>

                <div class="form-group">
                    <p class="labelish">Bateristas:(qtos):</p>
                    <span class="icon-case"><i class="fa fa-bars custom"></i></span>
                    <input type="number" name="bateristas" id="bateristas" data-rule="required" style="text-transform: uppercase;"  placeholder="Não há registro no banco" value="<?php echo $row_usuario['bateristaqtd']; ?>">
                </div>

                <div class="form-group">
                    <p class="labelish">Tecladista:(qtos):</p>
                    <span class="icon-case"><i class="fa fa-bars custom"></i></span>
                    <input type="number" name="tecladistas" id="tecladistas" data-rule="required" style="text-transform: uppercase;"  placeholder="Não há registro no banco" value="<?php echo $row_usuario['tecladistaqtd']; ?>">
                </div>

                <div class="form-group">
                    <p class="labelish">Violão(qtos):</p>
                    <span class="icon-case"><i class="fa fa-bars custom"></i></span>
                    <input type="number" name="violao" id="violao" data-rule="required" style="text-transform: uppercase;" placeholder="Não há registro no banco" value="<?php echo $row_usuario['violaoqtd']; ?>">
                </div>

                <div class="form-group">
                    <p class="labelish">Baixistas(qtos:</p>
                    <span class="icon-case"><i class="fa fa-bars custom"></i></span>
                    <input type="number" name="baixistas" id="baixistas" data-rule="required" style="text-transform: uppercase;"  placeholder="Não há registro no banco" value="<?php echo $row_usuario['baixoqtd']; ?>">
                </div>

                <div class="form-group">
                    <p class="labelish">Meia Lua(qtos):</p>
                    <span class="icon-case"><i class="fa fa-bars custom"></i></span>
                    <input type="number" name="meialua" id="meialua" data-rule="required" style="text-transform: uppercase;"  placeholder="Não há registro no banco" value="<?php echo $row_usuario['meialuaqtd']; ?>">
                </div>

                <div class="form-group">
                    <p class="labelish">Cajon(qtos):</p>
                    <span class="icon-case"><i class="fa fa-bars custom"></i></span>
                    <input type="number" name="cajon" id="cajon" data-rule="required" style="text-transform: uppercase;"  placeholder="Não há registro no banco" value="<?php echo $row_usuario['cajonqtd']; ?>">
                </div>

                <div class="form-group">
                    <p class="labelish">Outros:</p>
                    <span class="icon-case"><i class="fa fa-bars custom"></i></span>
                    <input type="text" name="outros" id="outros" data-rule="required" style="text-transform: uppercase;"  placeholder="Não há registro no banco" value="<?php echo $row_usuario['outros']; ?>">
                </div>

                <div class="form-group">
                    <p class="labelish">Ministério de carreira:</p>
                    <input type="text" name="ministeriocarreira" id="ministeriocarreira" data-rule="required" style="text-transform: uppercase;" placeholder="Não há registro no banco"  value="<?php echo $row_usuario['ministeriodecarreira']; ?>">
                </div>

                <div class="form-group">
                    <p class="labelish">Descrição (Nome dos ministérios de carreira):</p>
                    <span class="icon-case"><i class="fa fa-bars custom"></i></span>
                    <input type ="text" rows="5" name="nomeministeriocarreira" id="nomeministeriocarreira" data-rule="required" style="text-transform: uppercase;" placeholder="Não há registro no banco"
                           value="<?php echo $row_usuario['descrinomemstcarreira']; ?>">
                </div>

                <p id="demo"></p>

                <div class="form-group">
                    <center><button type="submit" class="btn-lg btn-success" onclick="myFunction()">Alterar & Salvar</button>
                </div> 
            </div>
        </form>
    </div>
</body>
</html>

  • You need to pass the codFiche parameter, you can add it in the same querystring in the href property that you have in element a, using &, and then pass the field and value.

  • Magichat how I do this did not understand where you refeiru, could show me please?

  • @Magichat how do I do this ?

  • Note that at the end of the url that makes the request has a '?', it should be '&'.

  • @Magichat should look like this if it is correct below: <a href='editarFichaCadastralMusica.php? Codusuario=<? php echo $row_usuario['Codusuario']? ><? php $row_usuario['Codusuario']; ? >&codFicha=<? php echo $row_usuario['codFichaMusica']? ><? php $row_usuario['codFichaMusica']; ? >&'><button type='button' class='btn-Sm btn-Warning'>View & Edit</button></a>

  • No, you have syntax errors. After the '?' starts querystring, composed of 'field=value', more than 1 field you add '&' between them, you are giving an echo and then repeating the needlessly.

  • @Ravlog I believe it should stay that way: <a href='editarFichaCadastralMusica.php?CodUsuario=<?php echo $row_usuario['CodUsuario']?>&codFicha=<?php echo $row_usuario['codFichaMusica']?><button type='button' class='btn btn-sm btn-warning'>Visualizar & Editar</button></a>

Show 2 more comments
No answers

Browser other questions tagged

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