Skip to content
Advertisement

How can I redirect to the same page with $_GET parameters in URL

i’ve got a question about redirecting. I put some parameters in my URL so I can use $_GET to get them out en them put them in a variable. Now, when I fill in my form wrong i get redirected but all the parameters are missing and they don’t are in the variables anymore. Is there a way you can redirect to the same page with the same parameters?

url with parameters: http://localhost:8888/WD2/Week6/Project/flight_bestel.php?stoelnr=5&prijs=99.00&bestemming=Spanje&aankomst=%20Barcelona%20Airport

url after redirect: http://localhost:8888/WD2/Week6/Project/flight_bestel.php

Thanks

JavaScript

Advertisement

Answer

So your question becomes…”How do I rebuild the original URL as the action for my form”?

One way to do that is to grab the query string and use it to rebuild your forms “action”.

Something like… Grab your original query string

JavaScript

And append it to your forms action

JavaScript

That should get your going in regards to that bit of the puzzle you are working on.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement