Passing data from a form on one page to form textbox on another page

0

How do I pass data from a form (query.php) of a page to the textbox and a radioButton of the form (cadastro.php) from another page without the action? Because I have two submit buttons for this same form (query.php) and would not like to use the action for the 2, I would just like to open the other page (cadastro.php) with the textbox and radiobutton filled out by the form on the other page ( query.php) with a submit button, the other button on the query.php page I would like when triggered to remain on the same page (query.php).

The query code.php:

if(isset($_POST['excluir'])){
            foreach($_POST['selecionado'] as $cpf){
               $sql = "DELETE FROM tbl_usuario WHERE cpf = '$cpf'";
                $result = mysqli_query($strcon,$sql) or die("<script type='text/javascript'>alert('Erro ao tentar deletar usuário');</script>");
            }
        }
        else if(isset($_POST['alterarConsulta'])){
            foreach ($_POST['selecionado'] as $cpf){
                $linhas[] = 1;
            }
            if(count($linhas) == 1){
                $sql = "SELECT * FROM tbl_usuario WHERE cpf = '$cpf'";
                $result = mysqli_query($strcon,$sql) or die("<script type='text/javascript'>alert('Erro no acesso aos dados');</script>");
                $dados = mysqli_fetch_array($result);
                $altcpf = $dados['cpf'];
                $altnome = $dados['nome'];
                $altsexo = $dados['sexo'];
                $altidade = $dados['idade'];
                $altcidade = $dados['cidade'];
                $alttelefone = $dados['telefone'];
                $altemail = $dados['email'];

                header("Location: cadastro.php");
            }
            else{
                echo "<script type='text/javascript'>alert('Selecione uma linha');</script>";
            }
        }
    
asked by anonymous 25.11.2016 / 22:55

1 answer

3

Assuming that the button is linked to the line that will be edited and with an ID that relates to it, you can use

jQuery('.meuBotao').click(function(){
    var id = $(this).attr("id");
    location.href = "meudominio.com?id="+id+"";
});

This form will redirect the user to another page with a GET leading the ID of the button that was clicked, this ID must be the same as the user you want to edit, and then on your other page you retrieve that ID with the $ _GET ["id"] and do a search on the database for the same with the ID, the data returned you add to the form within each input value

    
25.11.2016 / 23:27