Load reply to another page

Asked

Viewed 34 times

-1

I have a list of registered projects and the user can select one of them and click next to describe more details on the other page. I would like that, when pressing the forward button, besides being sent two data to another table and go to the other page, the data "id_rendering" be as if it were a session, since in the next form it will be sent automatically along with the other data. The two related parts are below. Another problem is that when I had not yet done this part of PHP from above, the user could normally select the projects that came from the other table, but after I did that there is no information appearing in the options. How can I proceed?

<?php
session_start();
include('classes/db_connect.php');
$query = mysqli_query($connect, "SELECT id_projeto, nome_projeto FROM projetos");

if (isset($_POST['avancar']))
    $sql = "SELECT * FROM prestacoes";
    $id_user = $_SESSION['id_user'];
    $nomeproj = $_POST['nomeProjeto'];
    $insert="INSERT INTO prestacoes(
      id_user,
      nome_projeto)
    VALUES(
      '$id_user',
      '$nomeproj')";
?>
<body>

    <form action="/user/registrarDespesas.php" method="POST" enctype ="multipart/form-data" name="prestacao">
    
    <div class="container">
        <div class="element">
        <div class="logo">
                <img src="confidencial"/ width="150px">
                
                </div> 
        
        <p><select name="nomeProjeto" id="nova" required>
        <option value="" disabled selected>Projeto</option>
        <?php while($prod = mysqli_fetch_array($query)) { ?>
        <option value="<?php echo $prod['id_projeto']?>"><?php echo $prod['nome_projeto'] ?></option>
        <?php } ?>
        </select></p>
        
        <p><button name ="avancar" action="/user/registrarDespesas.php" class="btn btn-grey">avançar</button></p> <br>
        <p><a class="link" id="fin" href="/user/selecionarPrest.php" style="text-decoration:none;">retornar</a></p>

        </div>


    </div>
    </form>
  • Where is the SELECT to perform the while from the bottom of your question. Because at the top there are two SELECT?

  • while below is taking the first SELECT that appears in the code, by mysqli_query .

  • if(mysqli_query($connect,$Insert)){ $prestacao = "SELECT id_prestacao FROM prestacoes WHERE id_user = $id_user"; $_SESSION['prestacao'] = $prestacao; $_SESSION['nomeproj'] = $nomeproj; header('Location: /user/registrarDesas.php'); } Else { echo "Error! Contact one of the ministers." ; } } ? > After entering this part of the code, would you tell me why $_SESSION['id_prestacao'] is being taken as null to another page? (It is the auto incremented type in the table)

  • It’s a bit confusing, it wouldn’t be better to post in each block the codes referring to each page?

  • Where is this $_SESSION['id_prestacao'] in your question?

  • instead of $_SESSION['rendering'] = $rendering; it should not be $_SESSION['id_rendering'] = $rendering;

Show 1 more comment

1 answer

0

You could not use type="Hidden input"

<?php
    <input type="hidden" name="id_prestcao" value=<?=$id_prestacao?> >
    
?>    

  • I’ve already solved this, Samuel, I’ve actually used the readonly method. The reason I don’t use Hidden is because it would be an output on the pro user interface to see which project it selected.

Browser other questions tagged

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