SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Nov 2006
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Is a double method=post on one page possible?

    Hello,

    This is tricky to explain, so please bear with me.
    I am trying to achieve the following page flow:

    1) I have a form that submits (method=post) to the same page.
    2) The information the user entered in the form is now displayed for confirmation (I checked for the submit with this: isset($_POST['submit'])
    3) If all the information is correct, the user would hit another submit button that goes to another page (action="confirmed.php" and method="post").

    The problem I am having right now is that when I reach the confirmed.php page, $_POST is empty. Is there a way I can fill up the HTTP_POST so that confirmed.php can receive the data?

    Thanks,
    Huy

  2. #2
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you could output the individual variables into hidden form fields and have them submit the new form. keep in mind users can manipulate values in any type of form field, so you will need to revalidate.


    another option would be to use sessions, which would eliminate having to revalidate as the data would be kept serverside.

  3. #3
    SitePoint Wizard TheRedDevil's Avatar
    Join Date
    Sep 2004
    Location
    Norway
    Posts
    1,196
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    If you process the form with php, the three most usual ways are:

    1) Put the data into a temp database.
    2) Put the data into a session, so you have it on the other side.
    3) Put the data into hidden input fields on the new form.

    Please note the options are not put in any order, it all depends on the specific project. There is also other ways to do it, but then we are getting more advanced.

  4. #4
    SitePoint Member
    Join Date
    Nov 2006
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Perfect. I think I'm going to go with the hidden input files since the application I'm working on is for internal use (no worries about security). =D

    Thanks for the quick responses!

  5. #5
    Worship the Krome kromey's Avatar
    Join Date
    Sep 2006
    Location
    Fairbanks, AK
    Posts
    1,621
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by huynguye
    ...is for internal use (no worries about security)...
    Not to pick on you, but I've heard this so many times before about applications that quite suddenly are opened up to the outside world. One of my current projects is in fact to close the numerous gaping security holes in one such app.

    Two main reasons why you should always follow best practices especially in regard to security:
    1) You never know what the future holds. This "internal use only" application could turn out to be so awesome that the bossman decides to share it with the world, and suddenly your servers get hacked because you didn't take a little extra time to write secure code.
    2) Bad habits are hard to break, but good ones shatter in an instant. Get yourself writing good, clean, secure code all the time, no matter what the application. If you do this, you'll find yourself always writing good, clean, secure code. Then one little "internal use only" application gets all your good habits in a knot!

    Besides, in your case it would be trivial to write your code securely - just throw the data into a temporary database or into session variables. Your plan right now is to put each into a hidden form field, so this is really no more difficult nor time-consuming and is infinitely more secure!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •