Form PHP, how to redirect with the data filled?

Asked

Viewed 82 times

-1

I have a question, and I will explain. I’m finishing up a website of an examination clinic, only that there is not possible to schedule tests, having to redirect to another site. On my site there is a field to fill, the "Password" and a "ok" button, after entering the password and clicking the button, the site is redirected to another that makes the scheduling. This other site has two fields "Unit" (which opens a dropdown with several medical units" and "Password". I would like when redirecting to this other site, the Unit field is already filled with the unit I want, and with the password that was typed in the previous site.

<form name="form1" method="post"
action="http://www.laudosonline.com.br/listalaudos.php" target = "_blank">
<input name="codnegoper" type="hidden" id="90|1" value="90|1" />
<input name="senha" type="password" value="" size="20" maxlength="20">
<input type="submit" name="Submit" value="ok">
</form>

I have passed this form only, sorry for the reasons I am an intern and I have been asked to do this. I thank you for all your attention !

  • codnegoper input is the field that holds the reference value of the clinic unit?

  • 2

    Hello Vitor, you have access to the code of the page that will receive this data?

  • Look the other website is yours? if you are to pass this data through the url and treat on the inputs on the side of it, but if it is not believe that it will not work! first pq tu esta enviar um post para uma url externa e dependendo da forma que o sistema de laudos foi desenvolvido ele deve ter uma proteção contra posts que não vem da pagina dele...

  • hello Matheus ! then I need to see with my boss when he arrives, but I believe not, I can do it without the other page code ?

  • sorry for the information Raza, I just saw, this form is the site that is redirecting

  • 1

    Vitor, explain better the situation of the two sites, which of them you have access to so we can understand the best way to solve your problem.

  • I got the information, this form is the site that makes the scheduling, IE, the site 2, I have to take the information of site 1 (in case the password) and redirect to site 2 and automatically fill in the password typed on the previous site, in addition to automatically selecting the unit. I have access to both sites. I was searching to do by the GET method, or by the POST that is safer, only I do not know how to do by the POST

  • If they are on different servers, you need to enable CROSS DOMAIN on the server you will receive, only this way you can do a POST to another server. If that is the case, I suggest you pass via GET the information.

Show 3 more comments

1 answer

-1

Well the only way to do that would be to request with Javascript, so when you hit the ok button you would call a function in Javascript that would send your data and not reset your form, it would look something like this.

In the form

<button id="enviar">Ok</button>

And no js

<script type="text/javascript">
   document.getElementById('enviar').addEventListener('click', function(event) {
        event.preventDefault(); 
        //Pega os dados e envia
    })
</script>

Event.preventDefault() will cause the action of the button inside the form not to happen

Browser other questions tagged

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