Skip to content
Advertisement

Storing $_GET and using it again in POST request

I am trying to store $_GET in variables and re-use them in a POST request, but the problem is that as soon as a POST request is sent the URL becomes empty and there is nothing to store in variables or the data stored in variables is removed as there is nothing in the URL

success.php?email=16564017@gmail.com&token=M3XK5HeCZy Current URL

after a POST request is sent the URL is success.php leaving nothing to store,

I’m trying to update passwords of users on basis of this method

I’ve tried this with $_SESSION, but cannot figure it out, My current work

JavaScript

HTML Form

JavaScript

Now, as soon as I submit the form, the URL parameters are not there anymore, so I want to store the URL parameters as I need to run queries based on it.

How do I store $_GET parameters such that they remain in a $_POST request as well?

Advertisement

Answer

This is how I’ve resolved this problem, I believe this is sort of a hack but it works, I am still looking for a better solution.

Validations
If there are no parameters in the URL it’ll redirect

JavaScript

If parameters found then :

JavaScript

and finally, before the $_POST request I am storing $email and $token in a hidden field so that I can further use it in queries

JavaScript

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