Advanced Search

Results 1 to 7 of 7

Thread: Forms help pretty please

  1. #1
    Join Date
    Jul 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Forms help pretty please

    Here's my situation. I don't know if it's doable. If it is it's probably ridiculously easy or ridiculously hard.

    Okay.
    HR fills out a form with some general info about a new hire.
    As a result, that information is forwarded as text in an email to the supervisor along with a link to a form that the supervisor must fill out with more detailed information about the new hire.

    I really do not want the supervisor to have to re-type the information that is contained in the email (for a number of reasons). Is there a way to invisibly mark those bits that I want to pass into the new form or hide them along with the link so that when the supervisor gets to the form, it is populated by as much of the information as we already have.

    Saving a partially filled form waiting for the supervisor to come back and finish filling it out is not really an option....I don't think.

    thanx/k

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

    Default

    There are several methods, each with some benefits and restrictions.

    1. You can include a limited amount of content in the URL.
    For example, http://my.com/form.php?employee=joe&...ger&date=today
    ...or something like that.
    However, there are character limits on this for some servers, somewhere around 256.
    If you have a limited amount of data, this is the easiest route. For anything complex, such as paragraphs, etc., this won't work out well.
    The URL can be used in a link sent in the email, so that's easy.
    The URL can only contain certain characters, so the text must be formatted properly. In PHP, you can do this with urlencode($variable).

    When this link is visited, the page in question will be loaded, and the information in the URL will be available to PHP or another serverside language (or, if you must use javascript only, that as well, but it is not a good idea). <?php echo $_GET['myvar']; ?> would output '1', from page.php?myvar=1


    2. You could store the information in a database when it is initially sent as well as including it in the email. The URL clicked by the supervisor could have information such as a username or employee name (see the above information) that would allow the form to know which employee's record is desired, then fill that content in automatically. This is the proper way to accomplish this (and most secure/reliable, since the information is backed up in a database).
    Also, if you don't have access to a database, it would be possible to store the information in files (such as .txt's) on the server instead, though less friendly and secure.

    The two approaches with this, though similar, would be that you could have the original person posting the data actually create the record in the real database, but have it simply deactivated (such as having a field called verified and that value set to 'no', thereby not displaying it in other records), or creating an entirely separate table (or even database) in which to store this temporary data.
    The former is a bit more convenient in that it allows for the form to simply be verified, the value of the verification field in the database to be updated to 'yes', etc., and that's it, rather than transferring all of the data back and forth. (This does assume, though, direct interaction with the final database for the records.)

    3. An interesting solution to this would be to send an html email with a form to the administrator. Basically, the email would arrive, with the form in it, and the information filled out. They could verify and submit, and be done with it.
    However, this requires sending out the right content-type header (and possibly other things) to get the email to be html-formatted, not plain text. And some email applications/sites don't allow html in the first place, so you would have to see if this works for your specific setup.
    It is a very clean way to do it, though.


    Note that with either option 1 or 3, the only copy of the data would be in the email, so it might be a good idea to implement a database or file-based backup anyway... so it might just be easier, once that is done, to use a database only.
    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
    Mar 2006
    Location
    Cleveland, Ohio
    Posts
    574
    Thanks
    6
    Thanked 5 Times in 5 Posts

    Default

    You could pass them along in the url the supervisor follows from the email:

    supervisor.php?e_fname=robert&e_lname=smith&age=20...etc

    Now, what I would do is I would have the form the employee fills out save as an html document with hidden form fields that the supervisor can click on a button, say "Fill your part out...", which will submit those hidden fields with the employee info to a script that makes those into session variables on the server, allowing you to reuse them whenever you need to (ie, in the supervisors form).
    Thou com'st in such a questionable shape
    Hamlet, Act 1, Scene 4

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

    Default

    Careful with session variables as they can be easily overwritten and can become unretrievable if the session expires (which can be quickly, if the browser window is closed or the user is idle for 10-15 minutes).
    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. #5
    Join Date
    Mar 2006
    Location
    Cleveland, Ohio
    Posts
    574
    Thanks
    6
    Thanked 5 Times in 5 Posts

    Default

    True, although in that situation, the session variables would be created and used before they would expire, I think. But you bring up a valid point, in reference to them being overwritten. If several people are using the same thing at the same time, sessions could be overwritten and that would be a mess.

    But, if my idea about creating an html file and linking the supervisor to that in an email, the supervisor's form can just be under the employee's information on that page, thus taking out the need for sessions, or even a database (although a database would probably be the best option, if supported).
    Thou com'st in such a questionable shape
    Hamlet, Act 1, Scene 4

  6. #6
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,156
    Thanks
    262
    Thanked 690 Times in 678 Posts

    Default

    Creating the html file isn't a bad idea, though it would also require that these files be deleted, or archived.

    the session variables would be created and used before they would expire, I think.
    Well, this assumes several things... 1. Time, which might vary, if it wasn't seen as urgent (since this system would make it feel like you could return later), 2. multiple forms at one time would be difficult, 3. session variables are only available to a certain user (ie from a certain computer), so the supervisor would need to come to the same workstation.
    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

  7. #7
    Join Date
    Mar 2006
    Location
    Cleveland, Ohio
    Posts
    574
    Thanks
    6
    Thanked 5 Times in 5 Posts

    Default

    True. Sessions wouldn't be fit for this situation.
    Thou com'st in such a questionable shape
    Hamlet, Act 1, Scene 4

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
  •