Possible to Dynamic Form Generation Using PHP global variables - php

Apparently there was confusion as to my original post so let me start over:
I am essentially creating an online shopping cart which gives a manager the ability to enroll his/her employees for training services which we provide. We charge $49 for the services for every employee enrolled. The primary difference between this and a traditional shopping cart however is that we must collect a solid amount of data about 'each' employee enrolled in the program - and this information is provided by the employer at the time of registration/purchase.
As a manager, I enter my personal information and then select how many employees I want to enroll. I currently have the site set up to handle 7 employees but actually need it to handle up to ~30. The issue I am having is the lack of dynamic ability and huge file sizes (especially in on the validation) I am running into.
Each fighter's information is passed and stored in session super globals such as: $_SESSION['F1Firstname']; and $_SESSION['F1SSN3']; and so on. I dont want to use javascript (and won't) to 'add another Enrollee' button because this can be turned off easily on the client side.
My assumptions are this:
1) I must be able to dynamically add variables to each new fighter so they may be stored in an online database and then passed along to our testing center - for example, emplotyee 1's name is F1FirstName; employee 12's Date of Birth is F12DOB1 and so on.
2) The validation for each employee will be the same based on each individual field (all first names must pass the same test). The validation for all email address must past the same email validation test and so on. If I simply build this by each individual record the validation file will be very large. I am thinking I need to add a Firstname array somehow but I'm not entirely sure.
3) I need this to be scalable that in the sense, I want a manager to enroll up to 100 employees, he/she can.
4) As I mentioned, this is like a shopping cart so a manager is enrolling all employees at once so they can pay for ALL of their employees in a single transaction.
Anybody got any ideas?

You can generate additional fields as needed by javascript. just provide a button 'add boxer' and there wouldn't have to be a lot of hidden fields.

If you're a "fairly new programmer" the best way would probably be to just have a form to input 1 fighter at a time. Not to mention this would be a lot more user friendly.

Related

Something to avoid conflict while saving to database

So I'm planning to create a code that will save in my database. (I have no problem in saving to my database thou.)
But I'm having a bit problem. The problem is to avoid having the same seat information displayed for the specific customer.
Something like this? (Sorry for the sample data that I will be doing.) The case is both are doing their inputs for their reservation at the same time.
[X] = taken data, [0] = blank data, [R] = customer data
1st viewing customer (having 2 data to be stored)
[X][X][X][R][R]
[0][0][0][0][0]
[0][0][0][0][0]
2nd viewing customer (having 1 data to be stored, and must be showed for this customer)
[X][X][X][X][X]
[R][0][0][0][0]
[0][0][0][0][0]
What the 2nd viewing customer actually sees. Which the customer mustn't encounter. And so on if there are other more customers are doing their inputs.
[X][X][X][R][0]
[0][0][0][0][0]
[0][0][0][0][0]
My first tactical plan is to create two database tables, one database table will serve as a dummy and the other will serve as the main database table. The logic is the dummy table will always update if there are customers making their inputs (which will have a problem by the time the customer closes the browser or didn't finish the transaction, the data stored at the dummy will still remain even after other customer accessed it again - which must not happen). And the main table will only update when the customer completed the whole transaction.
I know from the way I typed it is a bit confusing. But I really need some help in creating a logic to avoid this conflict the customer will see in my program. Or some tips if this kind of plan will not work. Like giving a note that (same sample above with 1st and 2nd customer) "This data is just a sample and sometimes will not be followed or the same with the e-mail sent to your registered e-mail addressed from this website."
Thank you in advance for your responses.
Well I don't think it's a good idea to save all clicks in final seat info table. Instead of that you can make something like temporary_seats base which will keep temporary information about reserved seats. In this table you would include information about seats that customers wishes to reserve.
Then you need to create javascript code querying API and getting all reserved (from destination table) and temporary reserved (from tmp table) and mark those seats free/occupied. You can do it constantly or check seat availability only when t

Let admin confirm database change

Our Symfony application makes use of Doctrine, in combination with the EntityAuditBundle to keep track of database changes. This works great for past revisions, the bundle almost exactly tells us what changes has been made.
The next problem is future database changes. Our customers are not able to change their user details, because we need to manually confirm those. Think of the following changes:
bank account number
email address
image of passport
Question: What is the best mechanism to let admins first review proposed database changes? The admin should be able to accept or decline the change.
Subquestion: Will this also work on Doctrine OneToMany and ManyToMany relationships?
For an app that I just finished, I had an Audit table set up - then info was sent in an email to a list of 3 admin emails through their outlook server, and I generated a link for a quick review with an "accept" and a "decline" button. The accept triggered a stored procedure with the Audit table's ID, copied the data to the normal table, then emailed the requesting user that the table was updated... Decline - held the data in the audit table, and forced the admin to enter a note which was emailed to the requesting user. There were only 2-5 requests a day and it was from employees (connected internally, so you could trust the requests more than promiscuous app data). There could be a much better way - but this method worked very well for me. Also, the audit table kept ALL data - all requests, regardless of whether or not they were granted. This was used for reports.

Approving information prior to storing in database?

I am developing a web-based iPhone app and possibly a PC friendly website version as well. The goal here to to allow users to submit a form where specific input values would be stored into a table in the database.
Mind you this information is being gathered for public display and will be posted onto a calendar or list.
However, to prevent from any trolling or spamming, I'd like to make it where submissions have to be approved prior to being submitted into the table.
I have no problem with creating the table, connecting to the database, storing input values into the corresponding table columns. The only issue is how would I go about setting up an approval system? Can I add information to a table via email? Is there a way to approve admissions in cPanel?
This is something that I would like make as smooth as possible, I am expecting a lot of submissions daily with quite a bit of information.
You can have two approaches for this.
Approach 1
Have two copies of the table (which you want to save information
into). The first one should be named tableName_Input. The second one
should be tableName_Final.
Any Data in '_input' is considered raw and needs approval. Once approved the data will be moved into '_final'. The LIVE list/calendar always read from '_final' data.
Approach 2
Have a column named 'isApproved' with a flag 0/1. If 1 it is approved, else it is not. Only show data that is Approved.
Now, how do you get the data approved ?
You have a hard fast rule like spam filter that tells certain post is valid and approved by default
After every post, you send the user an email or some notification (unique to the user - post) that when answered back, shall mark it as approved.
Optional: You can place a column called as 'approval comments' to fill in something at the time of approval.
Flow chart
Tables
'FirstSubmitContent' - Table to store user submitted information
prior to approval.
'FinalSubmitContent' - Table that stores the final information
Code Pages
Content Page --> Contains the form the user fills the content
ContentActionPage --> Calls the controller --> calls the Model
Controller --> calls the model based on page action
Model --> Interacts with the Database table
I do not have any tools at my disposable now to write more detailed Code or Flowchart. I hope this puts in the right direction.
Validate the form on submission and save info in a temporary table in your DB with a randomly assigned activation code (you could use sha1). Then send an email to user with activation code and a link to verify it, ie. domain.com/activate.php?code=abcde12345.
The activation page can be very simple with just a $_GET['code']. Then check if you find a match in the DB for that code and finally prepare your query with all the info you gathered before to store it permanently.
Then you can make a cron job to delete all records from that table every 24-48 hours so users will have to activate within that time range.

Controlling if a Submit button has been clicked once or more times

I have a registration form for groups of people, with 2 Submit buttons: (1) Add a participant, (2) Submit group registration.
When 'Add a participant' is clicked the first time, I want to create a database entry in some 'group' table (that will group together any participant added in that group). But then, when more participants are added as the group registration process continues, of course I do NOT want any more entry in this table. Just once.
It may sound silly but I can't seem to find a way to do that easily. Any idea? (I work in PHP with WordPress)
This is not a silly question and I don't see a way to do it without at least two buttons, or button-like elements, on a form. It is common to see this. For example, "Continue Shopping" and "Go to Checkout", not to mention the "Cancel" button. That shouldn't be confusing but don't get carried away with it.
This comment seems to be the key reason for your question:
someone decides to register several people at once to get a group discount
Based on this statement, I am working from the assumption that everyone has to register at the same time for this discount to take effect. That is, you can't register three people then come back later and register three more.
And the basic problem seems to be that you want to track how many times the form is submitted. Don't do that. Tracking how many times the form has been submitted is going to be a real headache. Rather than auto-generate a group the first time somebody registers, have an intermediary form for group registration. You'd have:
Register (Optional: Explanatory page with link(s) to the actual registration form)
Register Group (You can just generate an ID or have people name the group. This ID gets passed to the "add member" form)
Add Member (You can submit a member and redirect back to this form for another member, or hit "done" and go to a "Group" checkout form)
At the "Checkout" form you list group members and provide payment options. No idea how you plan to accept payment but it doesn't matter. Presumably you have some third party (Paypal, etc) to handle that.
Basically, you are tracking as much as closely as you can how the big shopping sites handle purchases so the whole thing stays as familiar as possible.
You can also have a "Single" registration form if you need one.
I don't know how you plan to prevent the spamming of this form. I'd suggest email verification at the group registration stage. That is, require some contact information from whomever is registering the group, send an email, and lock that group's registration until an email is returned. Spammers are unlikely to jump through that hoop.
You mentioned that you are using WordPress, so use wp_cron to clean up failed or abandoned registrations after some time limit-- 24 hours, three days, whatever.
Once the system works you can hijack it with Javascript and make it more dynamic, if you want.
Have a list of groups available for the 'create participant'. If a radio button (or similar) is selected for 'new group' (with appropriate info filled in) then create it when the participant data is submitted. Check for duplicates first, though.
As #ayman said - having two submit buttons is not a great approach. You will confuse your users.

User Friendly Registration System

I need to build a registration system which requires the collection of large data (many fields) from the user registering which is then inserted into a couple of tables in a database.
I don't really want to display a very long form to the user for the purposes of better UX.
This system will not run online, it is just a web app to run on the desktop.
I need help, pointers, references, etc on how I can better organize the registration process to make it more user friendly.
This How to encourage a user to fill in long application forms? has been helpful so far
As long as you don't mind requiring your user has Javascript, I would use AJAX. Let's say that you have 50 fields that you can logically combine into 4 different sets - the first may be about the person asking for name, email, etc., while the next set asks for historical information or employment information - like on an application.
Make one form for each set, and then present a new user with the first. When he completes the first page, instead of a "Submit" or "Register" button, use an AJAX call and a "Next" button to get the info and switch to the next page of the form with the next set of fields. You could use the AJAX calls to hold the information in a temp table in your database, and then, once the entire process is complete, you can write it to your member/users table.
You could do like other surveys or checkouts do and add a "title" for each page of the form above the form fields so that as a user moves through registration, they can monitor their own progress.
I'd recommend checking out the Amazon checkout, or really any multi-page survey (you may even be able to set one up yourself on Survey Monkey) to see how a large number of form fields can be broken down logically in a user friendly way.
Hope it helps.
Check out this link: http://www.smashingmagazine.com/2011/05/05/innovative-techniques-to-simplify-signups-and-logins/
It's talking about login- and registration-forms and how to make them more user-friendly. A suggestion which is also included in this article is as follows:
At registration don't ask the user to many questions. Only the basic data like their name for example. Then ask him about more detailed data when the user logs in the first time. This way the registration won't take too long.
Maybe this helps you out :)

Categories