0

The above pattern is supposed to be used as a workaround to avoid form resubmission, I.E
If some data is entered into a form on page A, posted to page B and validated + saved on page B. Then if the page is refreshed, the browser will show an error page as well as a prompt to let you know you are about to send all your data again (post it). This is bad, especially in systems which allow a bank transaction to be made; whereby with each refresh the same data is reposted and the request is remade, and the money is rewithdrawn.

To avoid it, the aforementioned method states;
1) user fills form on page A and presses submit
2) post request is sent to page B which in turn processes the data, if all validates the data is sent using the GET request
3) to page C

The problem I am having is how do you redirect from page B to page C using the GET request as page B is just a process & redirect page without a form. I would like to send the userid after it has been validated. Using a GET method to send this will allow for the url to be unique which can then be shared across users I attempt to have on my website.

I'm not able to do the redirect with GET parameters the following way;

    header('Location: pageB.php?q=$id');

The other methods I have thought of could be to put a hidden form on page B, and redirect to page C by submitting page B with javascript if validation returns true.

Another way I suppose would be to have an <a href='#' /> link which is clicked upon using Jquery if validation succeeds.

But these two use the methods which are aided by javascript which I believe may be unsafe (though I'd be happy if someone could reconfirm/refute this), and if someone has javascript disabled they wont be able to traverse to the next page.

If there are any other options available for me I'd really like to hear some!

Edited by asif49

3
Contributors
7
Replies
11
Views
4 Years
Discussion Span
Last Post by diafol
0

Your first method sounds like a good idea and I think it suppose to read:

header(Location: pageC.php?q=$id');

Since pageC is the target.

0

The page name isn't the concern here, appending parameters within the header() function in php does not work.

0

For parsing variables, you need to use double quotes:

header("Location: pageB.php?q=$id");

Edited by diafol

0

I also saw that 'solution' online somewhere, but that doesn't work either. Seems like you cannot append anything with the header() function at all. The next page simply gives the error;
Notice: Undefined index: q in path on line 4

0

Ahhhh! sorry about that, you helped me discover some other problem that was preventing this from happening in my code so thank you very much for that!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.