Jump to content

Passing post data to a new page with header()


little_webspinner

Recommended Posts

Greetings...

 

I have been staring at my whiteboard pondering a new architecture for processing data in an application.  New for me anyways.  I want to create a more centralized and modular method of handling data.  For ease of explanation I will put it into the context of a login system which is where I first started thinking about this.  I know there are a lot of login systems out there but I wanted to create one from scratch which utilizes PDO although that specific thing is not germane to my main question.

 

Here we go...

 

Lets say that for my Registration, Login and Forgot Password pages the forms on each page were directed to "Process.php" 

 

The idea is that process.php will provide the centralized platform to deal with data, acting as a choke point in the application making it easier to secure. This will also provide the means to quickly develop new parts of an application knowing that my methods of dealing with data area already well defined and secure.  There is one hole in the idea that I can see though.  If the user data being submitted to the process.php page does not meet the security requirements then the user must be sent back to the previous page.  I dont' want to lose the data they have already entered into the forms. ie. I want to have it appear in the form fields... makes sense right.

 

Now here comes my question...  is there a way to pass POST data when using header("location: http://mySite/previousPage.php")

 

It seems from my experiments that the data is lost.  I do not use header(); often.  In previous designs I have usually created each part of a login system as seperate and self contained entities apart from using a common db object.  I know there are other ways around this, using session data for instance but this idea has been eating away at me for a little while and I feel its time to ask around for some advice.  It has become a matter of curiosity.

 

I have found some info on sending POST data using header but it did not seem to meet the requirement that the user and the POST data be sent to another page synchronously.

 

At first I thought that maybe I would just do validation on the frontend / view pages (not to be taken as clientside) and if it was valid, then submit it to process.php, validate it again the let it be handled appropriately to its particular end but then I run into the same problem plus there is the extra overhead of validating the data twice.

 

I guess thats it for now.  Sorry if that was a little long-winded... its part of my process, helps me to better understand what I really want to know.

 

Using header() on a receiving page from a form page... the redirecting header() with POST data, sending the user to a new/previous page.  Possible? 

 

 

Link to comment
Share on other sites

There's really no value to isolating the page that displays the form from the page that does the work. Centralize your code with includes, functions and classes, not by arbitrarily redirecting your users around the site.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.