Results 1 to 9 of 9

Thread: Passing a value from one form to the next

  1. #1
    Join Date
    Sep 2007
    Location
    Maui
    Posts
    642
    Thanks
    284
    Thanked 15 Times in 15 Posts

    Default Passing a value from one form to the next

    I am trying to devise a system to enable online entries to a gym meet. Is there a better way to do it than using 3 forms whereby on the first page they enter the gym contact info, pass the gym_id to the next page where they enter the coaches (more than one), and finally the athletes? Once all the data is entered I was planning to display it on the screen so they can print the entry form from their browser. Is this the best way, or is there an easy way to create a pdf and email it to them automatically? Or??

    Thanks for any suggestions.
    Last edited by kuau; 11-25-2011 at 04:11 PM. Reason: figured out the first question

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    There are a number of scripts out there to generate PDFs using PHP. None are perfect, but if you're patient (and willing to debug them and fix issues specific to your site), then that might be the solution you want.
    I'm currently using mpdf on my site since it went pretty smoothly (that is, only a few hours to get it all working...)-- http://www.mpdf1.com/mpdf/
    There may be others that are available too. It's not easy to install everything but it's not ridiculously hard either. Note that using an output buffer (a nice trick to know anyway) will help you get your HTML content if you originally designed it to display on the page.

    Generally, though, it sounds like all you need to do is pass a GET variable to the next page, or perhaps a hidden POST variable to track what's going on. Organizing multiple forms can be complicated, but it's done all the time. So just work through all of it carefully and you'll probably find a way.

    Alternatively you could put the entire form on one page and use Javascript to "split it" using this script:
    http://www.dynamicdrive.com/dynamici...tipartform.htm
    The only problem is that the information is not saved between sections so you might lose everything if you don't notice that.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    $_SESSION also works well for this type of task. Unless it's a terribly long form, however, I'd go with Daniel's javascript suggestion.

  4. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Right. Or, if you need to process information along the way on the server (for example, create a new user profile, look up some suggested values for certain fields, then go to page 2), you'll need to keep the pages separate.
    The problem with sessions is that it will get confusing if they're filling out two forms at the same time (you won't know what data belongs to which instance of the form). Otherwise, sessions are easy.

    Another way to approach the whole thing is just to output the results of the previous form into hidden fields on each following page. It doesn't guarantee security (eg, the fields can be modified by someone who knows what they're doing), but as long as you trust the people who are working in the system and they have no reason to lie, then it's probably fine. It's a little annoying to set that up, but in general it's the simplest way to do all of this.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  5. The Following User Says Thank You to djr33 For This Useful Post:

    kuau (12-07-2011)

  6. #5
    Join Date
    Sep 2007
    Location
    Maui
    Posts
    642
    Thanks
    284
    Thanked 15 Times in 15 Posts

    Default

    Dear Daniel & Adrian:

    Thanks very much for the suggestions. For some reason I did not receive the emails from DD notifying me of responses, so I just got these now, and had to wing it on my own. I ended up using GET variables and 3 separate forms and then putting all the data together on the final page. I'd like to try Sessions someday but don't have the luxury to try something till I have to. I'm trying to avoid introducing pdf to the mix. So what I am up against now is having to protect the data. I want the entrants to be able to go back and edit their entries, so I figure the only way to do this is to introduce a login procedure (?).

    Is there a "best login script" out there? I found this one but haven't tried it yet. Dates on it seem kind of old... http://www.zubrag.com/scripts/password-protect.php

    One other thing I still need to do is write the code to send the owner a link to the final entry form. I haven't tried it yet but I'm wondering if there are any tricks to embedding a link with a query string in an email and if it will get messed up by the password protection. Can you use associative variables in the code to create the emails seeing as that page is not a form, eg. $gym['gym_id']?

    Thanks, e

  7. #6
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Well, I always write my own login scripts. That gives me all the control I need.

    Sometimes I do base them on an existing system. For example, I've use Simple Machines Forums software on some sites, then integrated logins with that. It sets up the database for me, then I can also have it already integrated with the forum. But the actual login system is all my own code usually, and I tend to disable the forum's login syste (for customization, integration, and also for security so I don't have two ways for the site to be attacked if a hacker tries to).

    In general for security, it's best to use a good custom script, rather than a standard script. Of course if you write your own script and it's bad, you might be hacked easily. But if it's good, it will be harder because the hackers won't know what they're dealing with. Just like breaking into a building, it's much easier if they already know what's inside.
    That doesn't mean you'll always be hacked if you use an existing, publicly-available script, but it is an advantage for hackers. I use SMF as I said, and that's been attacked a few times, but it's pretty resistant and they give enough update patches that it works out ok. Also, if the login script is secure and simple, that's probably also a good way to go, since there isn't any way to find a "back door" into your server if it just does one thing.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  8. The Following User Says Thank You to djr33 For This Useful Post:

    kuau (12-07-2011)

  9. #7
    Join Date
    Sep 2007
    Location
    Maui
    Posts
    642
    Thanks
    284
    Thanked 15 Times in 15 Posts

    Default

    OK, I'll try to write one and see how it goes. It's a fairly simple application (famous last words). Thanks! e

  10. #8
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Oh, I didn't explain why. The reason that I write my own login scripts is because it saves me time. (Not because I like writing lots of new code.) Integrating an existing script is often difficult and if you want complete control it may need to be rewritten piece by piece anyway. Even basing it on a system like SMF is complicated, but that can also be useful (especially if you later want a forum). But just using your own script is the most direct route. Of course that requires some experience with PHP, but there's no other downside. (And it gets faster and you can always borrow your own code in future projects.)
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  11. The Following User Says Thank You to djr33 For This Useful Post:

    kuau (12-08-2011)

  12. #9
    Join Date
    Sep 2007
    Location
    Maui
    Posts
    642
    Thanks
    284
    Thanked 15 Times in 15 Posts

    Default

    YES! That is what I want to do... have a simple php script (in which I understand every line) which I can use wherever I need a login. So now is my time to learn login scripts it seems. And I like the idea of it taking less time than to mess with someone else's code. That's actually why I am avoiding the pdf creator... a LOT of code I don't understand and, therefore, can't fix very easily, if at all. I'm sure I'll have more questions down the road.

    Thanks so much for sharing your experiences and reasons for doing things a certain way. It really gives me a lot of confidence (and others too no doubt)!

    Mahalo, e

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
  •