pre fill registration form - php

I have a registration form on my website and I want certain fields to be pre-filled when a user returns. for example first name, last name, job function etc but other fields to be left blank that are unique to the particular registration process.
what options do I have to do this for example user log in, "remember me"....etc ?
Also what are the pros and cons of these possible options(breifley)
any help would be great

I don't understand your question totally but maybe this will help:
a.) Store the pre register data in a database. Then when the user returns, just select the pre filled data from the db and then just display it as you like.
b.) Use $_SESSION in PHP.
[as I said, I don't know what you want to do...]

store the form data in the database and maybe compare user id with table id of the form table.
and something like that:
<input value="LOAD_DB_FIELD">

Related

How to show a survey form to users according to their role in wordpress?

I have created 3 form with the help of contact form7 and I'm using contact form DB to store the details filled by the user to the database. How would it be possible to show that forms according to the user roles and user can fill that form only once! If a particular user already filled that form he won't see that form ever. And while the user is filling the form all the features on the screen will be disabled.
I would propose to do this with two conditions
First:
If user is ....
Source: (https://codex.wordpress.org/Function_Reference/get_userdata)
Second: I would add a hidden field with a default value or just a simple counter.
If counter is ...

Best way to store data about problems in fields of filled form

As I am writing my program by PHP programming language and Mysql DB in WordPress CMS, I built a plugin to create and handle a customize form in a special workflow to the needs of our customer.
After form being filled by the user, one of the editor users of the site would check the data of the filled form and validate them.
The screen shot of the validation page that is show to the editor users is like this.
As you see I fetch data of the form from Data Base and print them to the editor users to validate them. At first all the field are display in green background. By using jQuery I give the editor users the ability to click on the filled that has problem and change the color of the field to red. like the below screen shot.
My question is, how could I store the data about which fields are filled with wrong data (The field that are showing with red background) and use this kind of meta data to create an edit page for end user to correct that fields?
Of curse there are a lot of way to do that. The easiest but in my idea not optimize way is to add Boolean fields match to the form fields in Data Base and submitting hidden field according to that Boolean fields to store the information that each field is correct(TRUE) or not correct(FALSE).
The forms that I am working on have about 174 field that most of them are varchar(254). So the size of data that is storing in data base is huge and I don't wanna make it larger.
Ultimately could you please help me. Is there any other way to store the jQuery actions of the editor users and show that stored data to end users.
I am looking for your help.
Bests.

How do I store form data temporarily if the form has to be refreshed and re-populated with that data?

I'm working on a recipe input form. The current version of the form is very basic....takes the data entered and inserts it into a recipe table.
I want to change this form so that the ingredients are no longer a simple text entry....rather i want it to be selected from a list of ingredients.
Here's what I've done so far...
- created a "recipe" table which has all the recipe data
- created an "ingredients" table which will be the list of ingredients to select from
- created a "recipeingredients" table which will be the list of ingredients selected for the recipe. this is just a id table...recipe_id and ingredient_id.
Here's what I need some direction on...
- When the user is in the addrecipe page, they would start entering in some information. When they get to the add ingredients portion they will have to click some sort of link that will open a new page to select ingredients. When they click that link, I would like to save all the form data they have already entered so this data can be repopulated into the form when they are done selecting ingredients.
How should this data be stored for temporary use?
SESSION variables?
DB entry without commit?
POST the variables back and forth between pages?
Please let me know if I can provide more information to be clear...
Thanks!
I'd use SESSION variables. That's the cleanest way in my opinion. A DB entry without commit looks a bit like a dirty hack to me. By the way, writing to a file is much faster. Using POST and input type hidden form fields could also be acceptable but keep in mind that the data is included in the html source code in clear text. And for bigger data it can make your source code a mess. You'd better store them in a temporary file. So, if you're using sessions anyway and your data isn't too big go for SESSION variables. Moreover if the data is of any confidential nature using SESSION variables or protected files on the server is obligatory.

Submit button and form handler from Grocery CRUD table view?

I have an app that has to send bulk email to selected users. I need to display my users table with a checkbox per row and a submit button with a form handler to operate on checked rows. Considering the built-in features of GC like the filter and column sorting, pagination, etc... I thought using GC would be a good solution. I found info on adding the checkbox. How do I add a submit button and form handler? Anyone have a hint or two where to start?
There are several ways to do this. I will explain two ways here.
Create the checkbox, for the id value use some unique data of the user details such as userid or username. After that on change of check box selection call a javascript method to update the hidden field with the current status. You can use some special delimiter to separate the check boxes. Let say if check box with id 1,5,6 are checked then the hidden field should be updated to "1#5#6". In the server side you can use the explode method to make an array and then you will have the usernames in array.
Another way is using AJAX and processing it immediately. I have used this way on my Codeigniter Code Generator at http://www.thephpcode.com to update the user roles' permissions. An admin user can grant or revoke permissions to a user role. All the permissions will be displayed with check box and with current status. When changed it will be updated immediatly through AJAX call.

Add to user input value before storing in the database

I have a form whereby a user fills it in and clicks submit. This then stores the information in the database. I have a field called height. And I want the user to type in something like 10, but I dont want them to type in the measurement aswel. I want this to be added to '10' before storing in the database
So when they click 10 and submit, i want it to show in the database as 10inches or 10".
I tried to google it but I get nothing because I have to be quite specific with keywords and I just dont know how to search it.
Does anybody know how I can achieve this?
Why do you want to store this in the database as text? That should not be a database concern, but instead be a UI concern. Store the 10, and just add the inches when you pull the data out?
Or you could store the 10 as a value alongside a mapping to what type it is (such as inches/cm/etc). This design will give you much more flexibility
You can use javascript to validate the textbox value on form submit (onSubmit)
In server php script, you could also check the value again.

Categories