Application Form Setup (Adviced Needed)

Posted on 2006-05-29
Last Modified: 2008-03-06
Hi all,
I'm developing an online application form and need the best way to store the information in the database. I haven't done a project similar to this before so my knowledge is a bit hazy :)
Basically, the application can either be joint (2 users) or single (1 user). I wondering what is the best way to design the interface to cater for this? Would it be better to build 2 different pages for each section, the first with only 1 field for each section (e.g. 1 username for 1 user) and the second page with 2 fields under the same row in the table (for 2 users). Or, would it be easier to build a page with 2 columns, column 1 for user 1 and column for user 2 and write some javascript so that when the applicant selects a single user, the second column is not submitted to the database .I problem with this second method, which would probably be a better solution, is that I only want to update the user 2 fields in the database if information is entered into them. Obviously when they are invisible no information would be entered into them. Is this easy to setup or does this happen automatically when I set up a statement in PHP similar to this:
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "server_form")) {
  $insertSQL = sprintf("INSERT INTO details_table (det_username, det_email_add, det_model_id) VALUES (%s, %s, %s)",
Any input on the matter would be greatly appreciated,
Question by:dereksheahan
    LVL 10

    Expert Comment

    This really depends on what the next step after this is.  It sounds almost like you want to create 2 seperate forms and have them both submit at the same time.  This can be achieved via javascript, but it can be tricky to deal with the results.
    LVL 29

    Expert Comment

    Maybe you should use 2 pages.
    Page 1. Ask if it will be single user or not
    Page 2. Serve the form applicable to the user choice

    Of course you should implement validation of the form fields...


    Author Comment

    Hi guys, yes I plan I having two pages like you suggest (TeRReF). I guess the main think I need to figure out at the moment is how hard is it to add or update two records to the one table at the same time? For example, on one page there will be two primary key auto-numbered user_ids created (two username fields, etc) and I want both of them to go to the one table in the database. How hard is this to achieve?
    LVL 10

    Accepted Solution

    It's a snap to update 2 records as long as you keep the field ID's clearly seperated.  As for doing it 'at the same time', I think it would have to be split into 2 calls (I don't *think* you can do 2 update calls on the same line), but it shouldn't be an issue either way as long as you're careful about naming the form fields.  Use different prefixes like user1_ and user2_ or some such when naming them to make sure they don't get confused for each other.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    Upload PDF On Mobile 1 41
    Bing Maps 1 23
    PHP and SOAP Woes 7 24
    Please help me with my database modeling 7 17
    Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
    I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
    The viewer will learn how to count occurrences of each item in an array.
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now