How can I pass a redirected parameter by clicking a button

Asked

Viewed 43 times

0

I am trying to send a parameter to another page .php when clicking a button, I would not like this parameter to be displayed in the browser, I tried it with this code here, but the parameter was exposed.

    function Oportunidade(pPar){
        var url = 'iAutenticacao.php?IdOportunidade='+pPar; 
        window.location.href = url;         
     }

I had also made some attempts with ajax, but without success. How can I do that?

  • I saw that you use PHP, you could use the MVC standard to do this. https://goo.gl/wtkKBz

  • I think javascript will always show the parameter somewhere in the browser. You shouldn’t worry so much about it. If this parameter is something sensitive to application security, it should not be used in javascript.

  • Hello, @Andreicoelho, you’re covered in reason

  • I just don’t say SURE, why I’m really not sure about this.

1 answer

1


You can put this button inside a mini form.

<form action="iAutenticacao.php" method="post">
<input type="hidden" name="idOportunidade" value="1234" />
<button type="submit">Enviar</button>
</form>

This is the only simple way to put the action the way you want, without the parameter appearing in the URL.

  • Thanks for the tip @cHida, helped,

Browser other questions tagged

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