I'm building a simple multi-screen form using codeigniter but I'm having some trouble working out how to keep the data and perform some tasks on each stage.
A bit of background on what it's supposed to do:
User lands on the home page with a form and fills out one field vehicle reg number.
They are then directed to another page that has pulled in their data relating to their vehicle reg number via a curl/xml request. As this web service costs per request, I only want to do this once per ip address, per day. Also, when a user refreshes the page it should not perform that call again, rather the data just be there already.
After the user is on this page, they confirm their details are correct, press next and enter their contact details.
Then they press submit and receive a confirmation message and one record is inserted into the database.
My idea for this was to record the users ip address. check the database to see if a request today had been submitted with that ip. If not, let it contiue, if so just give them a manual form to complete.
My question is how do I approach this so that when a user goes onto the next stage they have the previous data. Do I make each section a separate form that passes the previous data using hidden fields? This seems a logical way to me as I only need the data if it is a complete request. If they drop off, their data is useless to me anyway.
If i use this approach, how can I prevent the refreshing form and it trying to call via curl again?
Thanks in advance for any help.
Related
anyone here knows how to make a save and continue? I have a multi page form and it have many different parts so I need a save and continue form so they can fill out this form on the other day.
So firstly a user will log in into his/her account and they will see this link,
see image here
Once they will click on it, they will see a multi page form like this,
form image
When the user has filled out these data,
Sample data,
sample data 1
sample data 2
So when the user click save, the data that the user have input will be save so when they will log in back into his/her account the data that has been saved will be displayed in the form.
Saved data,
saved data 1
saved data 2
I have not yet tried any code because I'm new to php and mysql so please help! Thank you so much.
Each time a user selects Next, add the data provided by the user to the relevant row in a database table. In this row, have a status column with status 'Draft' until the user completes the form upon which you change the status to 'Completed'.
Each time a user opens the form, load any data already entered in the past by this user.
You might consider using a column to store information about the latest page of the form used by the user, so the user can resume at that particular page of the form later.
We are not here to provide you with all the code. If you have a problem or question related to a part of the code, feel free to ask though.
Good luck!
When the user clicks on the Next Button, Save the Data into your Mysql DB in a Save Block.
In the Save block user "INSERT" Query to Insert Data to DB.
After that use PHP "header" function to redirect to the same page.
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.
I searched a lot of places, but couldn't find solution.
What I want to do is:
submit a form on PHP server to another server, the request is to search some results back;
The search will take several minutes, so the other server will first return a progress html page, the will page will call back to ping the other server when the final result will be returned;
Get the final result page
The function is easy if form is submitted from browser. After viewing progress page, the final search result page will be returned and shown in browser.
But I don't want to show those on my client. I want to process that on my server, process data and show something else on my client.
Thanks a lot!!
You'll need some way of tracking whether a form has been processed or not - I recommend using a database entry. So here are the basics of your algorithm:
When the user submits the form to your client, you add a new record to the DB.
The required data from this form is sent to the other server.
Any client who accesses your page will be shown the 'Waiting' layout (because the complete DB column is set to '0')
When the processing is complete, the other server hits a listener script on your server, providing it the form ID. You then update the complete column in the DB to '1'
When the user visits the page now, they see its been completed.
I'm not going to write the code for you, but this functional overview should set you on your way.
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 :)
I am a bit of a PHP newb
I have developed a multi-page form which works fine at the moment - each stage is on another page (I use the session to retain the data).
However I know that users don't always use these forms the way you want!
I want to control the flow of the form.
I would like the user to be able to use the browser back & forward button for ease of use.
They should not be able to skip a part of the form by entering a form stage URL directly into the address bar to get the a later stage in the form (essentially skipping a part of the form).
The form also does not flow the same path every time, it is dependant on the users choices what stage is displayed next.
I was wondering if anyone had any ideas of ways to control the flow of this multi-page form thank you!
store form results in SESSIONS (encrypt them if sensitive)
then just check on each form if the value is set and show it as necessary.
use another session to check the "progress" of the form, to prevent the user from skipping ahead.
for example...
<?php
/* on form 3 */
if(isset($_SESSION['progress'] && $_SESSION['progress']==2)
{
//the second form has been filled out and validates
}
else
{
// the 2nd form hasn't been finished, redirect
}
?>
you could also use like a percentage based system in the session - a value of 90 means that 90% of the form fields have been completed - for displaying "progress" in a visual means to the user.
basically on every form submission, check whats been submitted, if its expected, then set appropiate sessions to redirect to the next stage.
check every set session on every form to determine if the user should be here yet.
Push the data for the non-current fields into a hidden field in the browser (to save time and effort - just serialize an array/object).
I would like the user to be able to use the browser back & forward button
If users are allowed to re-enter previous stages, just let them and rewrite current stage in the session.
If not, make form fields read-only and do not process submitted forms for the previous stages.
That's the only problem I can see here.
You can either use session data to retain the state between multiple pages, or you can transfer all data on each page. Typically you would do the latter with hidden fields or you will create one humonguous form, and use javascript to make it appear as if it was multiple pages, when - in fact - it's not.
There are pros and cons to each solution.