Passing parameters from one page to another in PHP

Asked

Viewed 712 times

2

I have a data listing on a page. There an 'edit image' serves as a link to another page where this data is displayed again (in addition to the other data of the client) and it is possible to edit them. As follows, the target page is edit.php

In this link I want to go through parameter the client ID so that on the screen edit.php I can manipulate this client and display his data again. All via POST.

had thought of something like: href="edit.php? Fields('id_usuario'); ?>"

  • 1

    Want to post the code so we can take a look?

  • But this method that you put there is via GET, via POST is different... But you can do so yes, ai only in your query search where id = $_GET['id'];, edit.php? id=id_usuario

  • $sql = select" here selects the data in the database "; $usuarios = Query($sql, $connected); so far all right. is taking the values at the base and displaying on the screen in a list. for each name displayed in the list, a link appears to click and edit, where a new screen is opened with these fields already filled and available for editing. the link that leads to the new screen is: <a href="edit.php? id=<? $usuarios->Fields('id_usuario'); ? >"><div class="col" style="width:25px" align="left"><img src="Edit.png" alt="Edit" name="id"></div></a> passing the parameter thus not working

  • Posted as question @Phpdeveloper

1 answer

1


Friend,

to send the id_usuario via post, you have to send with ajax.

That would be about it:

$('#link').click(function(e){  
                e.preventDefault();
                var valores = $('#link').serialize()
                console.log(valores);
                $.ajax({
                url : editar.php',
                type: 'post',
                dataType : 'html',
                data: valores,
                beforeSend : function(){
                    $('#carregando').show('100');
                },
                //colocamos o retorno na tela
                    success : function(pre){
                        $('#carregando').hide('100');
                        $('#retorno').find('strong').text(pre).end().show(100);
                    } 
                });
            });
        });
  • A detail! you will need to retrieve the id in ajax as a date and send it to edit.php. I believe that with some small changes you managed to succeed in this application.

Browser other questions tagged

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