I want to build a script a register form and then divide in to parts, let me demonstrate
Accept rules (then press Continue)
Type username, password (then press Continue)
E-mail (and so on) and then Continue
To finally put all data and submit in to a database
But I'm not really sure how to do it, should I use sessions?
Give me some ideas of how you would have done it.
If you're going to do it in PHP, your best bet would be using PHP's Sessions. Take input from the forms on each page and store it in a session.
Insert all of the users information into a database in pieces with a timestamp, and if the user clicks cancel or doesn't come back to filling in their user info the database their information will be deleted.
Use jQuery SmartWizard or something like that.
Related
I'm looking for a way to create a page with items on it where each item has a button which can be clicked to "like" or "choose" the item. The website would then remember the choices and input them to a form on another page. Is there anyway of doing this?
At first glance if we are talking about a registered user, i would create fields in the database for the user's input and store its value everytime he makes a selection. Then its only a matter of putting those values wherever you want.
You have several choices. If it is persistent data, I'd suggest a database like MySQL. If you don't have access to that, then Google for "flat file database" and you'll find some great ideas.
If the data is persistent, but not a big deal if it gets deleted or spoofed, you can use cookies.
If the data is fleeting (it goes away at the end of the visit), then use sessions.
The best way to do is storing each result in a SESSION and reusing it in other form.
I am helping to make a website in PHP which is an ERP purpose website. We made mockups of a form to collect user details which is split into 4 screens facebook style where the end user keeps clicking next after filling in each partial form. Finally they get the preview and confirmation receipt is generated.
How should I go about this in the backend, I am sure that after the preview I will write the values to the Mysql db and generate a receipt. My question is how do I go about storing the values before the preview?
you can use php sessions to store the variables in a session and then at the end store them all in the database.
http://php.net/manual/en/features.sessions.php
You cannot really answer your question in isolation. It really depends on how your user is going to use the system, whether the information they enter should be persistent, and even whether you know who the user is?
Assuming you know who the user is, and you want to keep failed sessions, my suggestion would be to store the partial responses in a database so you can always access them later.
You can then populate or re-populate the form as you wish. You should also have a "start again" button in this scenario.
More information would help give a better answer.
You can just have one form per screen/page and send these values as parameters to the next page via post or get - it's the most simple way
It is also possible to keep all the form markup on single page and divide form into steps using formToWizard jquery plugin.
http://www.jankoatwarpspeed.com/post/2009/09/28/webform-wizard-jquery.aspx
This way user has all data available when users clicks and back and forth during the steps and you can just have single submit button.
This is inside a PHP website form.
An example is like:
First page:
-Username:
-Password
Second page:
-Email
-[Checkbox]
Thirdpage:
-Contact Details
-Address
Fourth page:
Review all of the above forms in hard copy but with a back and forward command so that the user does not loose any information when switching between these pages.
Please post.
You could use cookies and do your own sessions with MySQL too. I like doing it like that because the data is easier to access if necessary.
Or you can pass the previous variables to the next page though hidden form elements.. but that can get messy.
You Have to use session. I like Zend_Session.
If you want users to be able to come back later and complete the form (assuming you have some kind of login system, or a way to recognize users), you could still save the data into a database. Make another table, temp_submissions. Keep data in it until the user completes the form and commits the data they send. Once committed, clear the data out of the temp_submissions folder and insert it into the "permanent" table. It may not be practical in this case, or total overkill, but it's an alternative to sessions and cookies.
Hey guys, I have a form with 3 fields 1 input, 1 select and 1 textarea. Is there a way to store the information as they type?
The reason why I need this is because if you are not logged in the submit button will take you to a fancybox with another login form or a signup one. So of course if the user logs in the page is refreshing and they loose the text they inputed.
Thanks.
You can totally use YUI's Storage module, it'll hold everything in 1) HTML5 memory, 2) SWf memory 3) Google Gears memory 4) ysql or something, so I read.
I've tested HTML5 mem and Swfstore, both ace.
Edit: Here's an excellent YUI Storage example, it counts every 5 keystrokes, perhaps you'd call the same save method when focus leaves the form handles you're working with.
AJAX could do this, though you are probably better off passing the contents of the inputs in POST and retrieving them if the page is reloaded as a postback from the login page.
There is no trivial solution to this problem. The simplest way to overcome would be asking login screen before asking for user input.
YUI storage module answer is a great option. Otherwise, you're going to have to change the behaviour of the authentication logic which automatically redirects you to the login page. You would have to store the posted values in some temporary server-side location, and re-post those values after the user logs in.
Another option would be to authenticate the user via a dynamic HTML login form and Ajax before actually submitting the form. Either way it changes the authentication logic of your application a lot.
Actually, I think the root of the problem is that you're presenting the user with a form which requires authentication to use before they are authenticated. I think you should either force the user to authenticate before presenting them with the form, or don't require authentication for posting the form (which probably isn't a good idea).
The most straight forward and simplest way that first comes to mind:
Store the information in a cookie - first thing when they hit submit so you have what they typed at any time, logged in - out - hour later, maybe even next time they visit etc.
If you can't use a cookie, maybe save it to the database in a temp table of some sort, relative to a specific session or anonymous user....
as you mention i think you can use simple SESSION variables for all your fields OR you can use AJAX.where you can popup one light-box at the same page and then login and process further you want.
Thanks.
I'm taking a class in PHP and I'm a real newbie when it comes to best practices and whatnot.
I have a little homework that the teachers wants me to hand in.
Create a form that asks a user for his name, last name, age and birthday.
When the users clicks submit, take him to the second form and ask for his location, nationality and religion.
Finally when he submits that, take him to a 'thank you' page showing all the written information he input previously.
I'm thinking about using GET to pass things along, but I've only done this with one form to another, not multiple 'hops'. Would this work?
What other way do you think I should do this? I'm not sure if this should be community wiki because I'm sure there's a perfect answer, but please let me know and I'll change it.
Thank you SO. :)
You need sessions. Sessions store an ID on the computer, (sometimes in a cookie) that references information on the server. You just create a session, and then you can put whatever data you want in it. Just grab that data on another page whenever you want.
page 1
session_start(); // start session
$_SESSION['name'] = 'Jimmy'; // put something into the session
And on the next page...
echo $_SESSION['name']; // echos "Jimmy"
session_destroy(); // don't want the session anymore
More info at http://w3schools.com/php/php_sessions.asp
Use session.. Make sure you clear it when you are done saving the data.
when rendering the second form you could include all the fields from the previous form as hidden fields.