I am looking for information on how I can use a database to fill in parts of a form.
I have a Notify Me form that will be available on two different pages. On the first page, the customer will have to fill out the entire form. (Ensuring I know what item they want to notified about.)
On another page is a database in which I will have all the items listed plus item that are not yet available. (The database entry will be seen before the item is available and the notify me form will be a marketing tool the item.)
I want to include a link to the same Notify Me form, as seen on the first page, in the database, however, I would like this form to check the database to see if the item is already entered, and if so, fill out that information in the form.
Notify Me form
Field 1: Customer Name
Field 2: Email
Field 3: Model Number of item
MySQL Database
Field 1: Type
Field 2: Model Number
Field 3: Price
Field 4: Link to form
So, as you can see the Model Number is in both the form and the database. If my customer clicks on the link for the form from within the database (Field 4), I want Field 3 of the Notify Me form to be automatically filled out with the value in Field 2 of the database with in the form opens.
Not quite sure what you're asking, but maybe this is what you need?
<?php
$modelNumber = mysql_fetch_array(mysql_query("SELECT ModelNumber FROM ? WHERE ?"));
?>
<input type="text" name="modelNum" value="<?php if ( $modelNumber != "") { echo $modelNumber; } ?>"/>
Related
I am using ACF repeater field for user profiles, which shows like this in the user profile page:
That's cool.
But on the front-end I have a form that I want to use to delete a specific row. My custom form simply lists all the rows with radio buttons, and so if the user selected number 3 and submitted the form then I want to delete the third row (in this example, the row with Catherine Davies would be deleted).
The form works fine in that it submits as expected and returns the value the user selected, but my code to delete the row that was selected doesn't seem to work.
The ACF documentation seems a little vague on the subject. Based on a combination of the ACF doc and this StackOverflow post, I expect this code to work but it does not:
$user_ID = get_current_user_id();
$field = 'extra_user_info'; // Name of the repeater field
$row_to_delete = $_POST["row_to_delete"];
delete_sub_row($field, $row_to_delete, 'user_' . $user_id);
Just to be sure, even if I hardcode the $row_to_delete variable to any number (from 1 to 4) it still does not delete any row.
Just to clarify, I wish to delete an entire row.
Note: I realise I could just embed the ACF form on the front-end, but for reasons I won't go into this is not an option, hence using my own custom form.
There could be another issue but in your example at least, your $user_ID variable has capital letters, while the variable passed to delete_sub_row() is lowercase. PHP variables are case-sensitive.
I have 2 forms, each one is on a different page, and they both fill information in the same table in the database. Whenever I try to fill them up, the database displays the information as 2 entries, how I can I display the information in the same row in mysqli?
(first form asks the user to submit first name and last name, second form asks him to submit email and phone number) putting them in one form is not an option.
I have two forms in the same page, the first form will have email, name, password etc.
In a second form there are qualification, skills, institution etc.
I will add data from the first form into one table. I want to take the ID of the data from the first form and add qualifications, skills and institution in another table along with the ID from the first form.
I am doing this in php. Please give me an idea how to implement this.
try to do it with Ajax
User enters email, pass..etc, and clicks submit button after that trigger Ajax Call with form data. Store the data in your table and return Mysql Last Inserted Id. Store Last Inserted Id in your load JS Variable/HTML Hidden value.
Steps :
- User Enters Details and press Submit button
- Ajax call triggers with your data
- get Last Insert id from back-end(ajax response)
- store id in html hidden value or js variable
- use this details for next form
Suppose I got a webform with some fields like "Name, Surname, Address, Phone, Email, Preference, Hobby". What I need now is when a user is filling the form, Suppose he fills the Name field, the data is stored in the sql table, same goes for surname, once surname field is filled now Name and Surname will be saved in the table. The save must be done on the lost focus event of each field. The user can abandon the form filling anytime, even if the form is not completely filled.
The form by default has the status “Abandoned” which is stored in a hidden field, but once all fields in the form have been completely filled, this status should change to “Processed”.
Can anyone please suggest or get me an example of how this can be done?
You can implement this logic:
Add additional field in database for session ID
On lost focus, call ajax to update DB's field and you can check
record with session ID field.
you can also check using PHP for all fields' value to identify record
status instead of javascript update in hidden field
i have a database with these field
member id(mid),sponsor id(sid) ,sponsor name(sname)
and a joining form like as
now i want to add this feature when i type a sponsor id then its tell me this id is available in database or not ...and if not available then it show message front of this field and if yes , then when i click in sponsor name field its automatically fill the name of sponser of this id ..and i want all this happened before click submit button..thanks..
Please use the JQuery validate plugin for this. Below is the example that how to use remote function in this plugin.
http://docs.jquery.com/Plugins/Validation/Methods/remote