WordPress How to capture data from forms submitted by users - wordpress

I want to collect data when the user fills out the form and submits the form.
Once the data is collected, I want display the submitted data on an another page in a table form.
I'm not sure how to achieve this WordPress, please guide me how this can be achieved.
Most of the data will be numeric and displayed results will be calculated.
thanks
Neil

I suppose that you use POST method in your form, and that when the user click on submit button it will go to mypage.php (or the page in action attribute of the form. Then, in that mypage.php you get the values of the form using $_POST variable.
For example if the form is
<form action="mypage.php" method="post">
<input type="text" id="mytext" name="mytext" value="write a text">
</form>
then $_POST['mytext']
will let you know the user entry.
If you used GET method instead, it's the same, but with $_GET['mytext']

Related

How can I re-insert the values on a form, after a user clicks to edit something?

I have a single template that's wired up to show a post if the current user has a post in the collection. If not, it automatically shows a form.
Now I want to add an EDIT functionality. When the user clicks on the Edit button, it
Saves the post text in a variable.
Deletes the post from the collection, thus the template reactively reveals the form again.
Up to this part it all works. How can I then add the text that I just saved in a variable, into the "input" element of the form?
jQuery works for this on the console, but I don't know where to put it in my code.
On Discover Meteor, they use the Router to set the context. I'd like to try my idea with jQuery, if possible.
Thank you. Any suggestions are welcome.
You could keep your post in a session variable and in the edit click handler, set the session variable to the one you're currently viewing.
In the form inputs, you can set the value attributes to their corresponding post values.
ex: <input name="title" value="{{post.title}}" />
and in your template helper
Template.form.helpers({
post: function() {
return Session.get('post')
}
})

Validation in a modal form

I am updating our site that is used for our people to enter in orders. The first page gathers the customer information. The user currently clicks on a button that brings them to a secondary page where they can enter part of the customers name and it will return the correct customer code. The site is written in asp using sql.
I am trying, with html5, css and asp, to redesign the form so when the user clicks on the button, they will get a modal form where they can enter in part of the customers name. It would then return the id number and put it on the main page and close the modal form or it would return a not found error.
I have the asp code but where I am having an issue is how to load up the modal form. I can show a modal form from a page - but how should I handle the validation? The form itself is basically written in the html 5 page.
Thank you for your input.
George
If you are using jQuery then this is already supported. Each form element can have required to validate against empty input fields.
You can go further with changing the type attribute. For example this one requires email addresses:
<input type="email" required placeholder="Enter your email address" value="" />

ASP Disable button and run function

I want a webpage that will disable a button and run the function, after the page is refreshed the button will be re-enabled. The button are created with the method below. The problem is when I click on the button, it can disable but it wont runs the function, the page won't even refresh. No idea where the problem arise from.
set common = server.createobject("Pen_Ebizcommonproc.stringproc")
<%=common.writeButton ("Submit1","Submit","Create New Sales Contract",30,"onclick=""this.disabled=true;CheckGWidth(this.form);this.form.ContractType.value='N';""")%>
What I do mostly is extract it in a javascript function.
I remember that disabling a button cancels any following inline action of that button.
<form action="test.asp" method="post">
<input type="submit" onclick="doSomething(this);" />
<input type="text" id="ContractType" name="ContractType" />
</form>
Then in the javascript
function doSomething(sender)
{
sender.disabled=true;
CheckGWidth(sender.form);
sender.form.ContractType.value='N';
sender.form.submit();
}
Hope this is of any help.
I have had to do this a few time so that refreshing a page and revisiting a page is treated differently to one's first visit or after submitting one part of a form when there are more than one forms on a page, like when calculating updates for a shopping cart.
Depending on the scenario I used cookies to record the page loaded so that I could detect if it was the first visit, a refresh or what. If you have two buttons for things like "update" or "finish" they can use seperate forms with different hidden fields for mode=update or mode=finish.

Question about plentyoffish.com asp.net functionality

One the frontpage of plentyoffish.com, the 'Continue' button (for the form submission) links to register.aspx. From what I can see the system does not use postback. So, my question is, how is the form data posted to register.aspx? What would that code look like?
i'm not sure if we're talking about the same thing here, but the continue seems to be an image type input, which works the same as a submit, and submits the form to register.aspx.
If you look at the html source of the page, you will find the following code
<form method="POST" action="register.aspx" NAME="Register853049" onsubmit="return submitForms(this);">
The action is specified as register.aspx, so when this form is submitted to the server it is submitted to register.aspx

how do i make it so someone will fill out a form on my site, and then get redirected with to another form with the values already filled?

I am using a wp blog and I want leads to come in to go to be via email and then get refered to another website with the values already filled in?
I want to use php, but i will use anything that works.
does anyone know how to do this?
In HTML, when marking-up a form, you can specify default values. So for example:
<form>
<input name="firstName" value="John">
<input name="lastName" value="Doe">
<button type="submit">
</form>
So, once the user submits data from the first form, you can write the HTML in the second page with the user's information placed into the form already. By default it will be there, but it could be edited again if he/she chooses.
I don't use WP, but I'm sure you can grab the data coming from the first form, then emit the same when generating the next page.

Resources