Thread: Form Submittion

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2010
    Posts
    11
    Rep Power
    0

    Form Submittion


    Hi All,

    I have a form that people can fill in but I wish, once they press submit, for them to be taken to a page that displays the fields and the data they placed against it.
    Then a submit button that posts to my DB (already have) and an edit button where they can go back and modify what is incorrect before submitting again.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2003
    Posts
    3,571
    Rep Power
    595
    Welcome to the forum. Please see ManiacDan's New User Guide to learn how to post a question that will produce useful help.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2010
    Posts
    11
    Rep Power
    0
    Hi,
    What more information would you like me to provide?
    I was under the impression that I have supplied enough information to produce a useful answer?
  6. #4
  7. Confused badger
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Mar 2009
    Location
    West Yorkshire
    Posts
    1,161
    Rep Power
    492
    I think what gw1500se is trying to ask is "What is the actual problem" or "where are you stuck"? You've simply provided a "I wish for..." which is great and we're all behind you in achieveing that but other then that, you don't say what the problem is preventing this wish coming true or what you've tried so far (if anything).
    Last edited by badger_fruit; November 1st, 2012 at 12:42 PM.
    "For if leisure and security were enjoyed by all alike, the great mass of human beings who are normally stupefied by poverty would become literate and would learn to think for themselves; and when once they had done this, they would sooner or later realise that the privileged minority had no function and they would sweep it away"
    - George Orwell, 1984
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2003
    Posts
    3,571
    Rep Power
    595
    And if you had read the link, you would have understood why what you presented is not enough.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2010
    Posts
    11
    Rep Power
    0
    Oh ok, well the problem is I do not really have any idea where to start.

    I have my table set up in MySQL DB, I have the form working fine. When I click submit currently it places the info into the DB and tells me that it has been submitted.

    However I want to add the middle man, but showing the user what they have entered before submitting this information to the DB
  12. #7
  13. Confused badger
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Mar 2009
    Location
    West Yorkshire
    Posts
    1,161
    Rep Power
    492
    May I suggest that if you have the 'write to DB' bit working then you keep it like that but on the confirmation screen, simply re-create the form and set the "values" of the HTML elements to the values submitted by the user.

    For example, in this confirmation screen below, the user submits their name using HTTP POST ... I'll skip the write to DB bit but what we need to do sanitise their input using HTMLENTITIES and then write that back to screen ...

    PHP Code:
    if(isset($_POST['name'])) { $name htmlentities($_POST['name'], ENT_QUOTES'UTF-8'); }
    echo 
    "<input type='text' name='name' value='{$name}'><br />"
    That's just a rough idea but hopefully will set you off in the right direction
    "For if leisure and security were enjoyed by all alike, the great mass of human beings who are normally stupefied by poverty would become literate and would learn to think for themselves; and when once they had done this, they would sooner or later realise that the privileged minority had no function and they would sweep it away"
    - George Orwell, 1984
  14. #8
  15. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2010
    Posts
    11
    Rep Power
    0
    Originally Posted by badger_fruit
    May I suggest that if you have the 'write to DB' bit working then you keep it like that but on the confirmation screen, simply re-create the form and set the "values" of the HTML elements to the values submitted by the user.

    For example, in this confirmation screen below, the user submits their name using HTTP POST ... I'll skip the write to DB bit but what we need to do sanitise their input using HTMLENTITIES and then write that back to screen ...

    PHP Code:
    if(isset($_POST['name'])) { $name htmlentities($_POST['name'], ENT_QUOTES'UTF-8'); }
    echo 
    "<input type='text' name='name' value='{$name}'><br />"
    That's just a rough idea but hopefully will set you off in the right direction
    I hadn't thought about doing it this way really, I don't really want duplicates in the DB and also on submit it produces an email which I would not want them getting many emails for the same form
  16. #9
  17. Confused badger
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Mar 2009
    Location
    West Yorkshire
    Posts
    1,161
    Rep Power
    492
    Well, it was just a suggestion, you can of course, use that code above BEFORE it updates the DB and only have it update on their next click of the 'submit' button.

    Oh, by the way, this method I suggested wouldn't end up with duplicates, at the point of displaying the form it's INSERTed the record and you can get the unique ID that is returned from the INSERT statement and use that in a hidden field.

    It's up to you of course, as long as you make it clear to the user that "AT THIS POINT, YOUR DATA HAS NOT BEEN SAVED" then do it however you like but don't ever forget how dim users can be - even with a 72pt bold, flashing, red on yellow banner, it'll be ignored by them and they'll be left wondering why, when they closed the browser at that point, they have to re-do the entire form.


    EDIT > With regards to the 'Thanks for submitting your data' email, only do that AFTER the data has been written to the DB, if the user then EDITS their submission, you don't need to re-send it (as you'll know if you're doing an INSERT or an UPDATE)
    Last edited by badger_fruit; November 1st, 2012 at 01:36 PM.
    "For if leisure and security were enjoyed by all alike, the great mass of human beings who are normally stupefied by poverty would become literate and would learn to think for themselves; and when once they had done this, they would sooner or later realise that the privileged minority had no function and they would sweep it away"
    - George Orwell, 1984
  18. #10
  19. No Profile Picture
    Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2003
    Posts
    3,571
    Rep Power
    595
    Alternatively you can define a column or combination of columns as unique and update the database on the first submit. There would need to be some way to connect that column with the user (perhaps a username) to prevent inserting a duplicate record. Then after editing, do an update rather than an insert using that value in your where clause.

    One final method is to manage all the editing on the client via javascript and then the submit would only need to be done once.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  20. #11
  21. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2010
    Posts
    11
    Rep Power
    0
    Originally Posted by badger_fruit
    Well, it was just a suggestion, you can of course, use that code above BEFORE it updates the DB and only have it update on their next click of the 'submit' button.

    Oh, by the way, this method I suggested wouldn't end up with duplicates, at the point of displaying the form it's INSERTed the record and you can get the unique ID that is returned from the INSERT statement and use that in a hidden field.

    It's up to you of course, as long as you make it clear to the user that "AT THIS POINT, YOUR DATA HAS NOT BEEN SAVED" then do it however you like but don't ever forget how dim users can be - even with a 72pt bold, flashing, red on yellow banner, it'll be ignored by them and they'll be left wondering why, when they closed the browser at that point, they have to re-do the entire form.


    EDIT > With regards to the 'Thanks for submitting your data' email, only do that AFTER the data has been written to the DB, if the user then EDITS their submission, you don't need to re-send it (as you'll know if you're doing an INSERT or an UPDATE)
    This sounds like a wonderful solution then I will attempt to put this into action tomorrow and let you know how it goes Thanks!!

IMN logo majestic logo threadwatch logo seochat tools logo