store data in drupal 8 - drupal

I have created form using twig template, the form has first name,last name and email.I need to save those values to database.
how can I create new table and store data in it??
<!DOCTYPE html>
<html>
<body>
<form action="/action_page.php">
First name: <input type="text" name="FirstName"><br>
Last name: <input type="text" name="LastName"><br>
Email: <input type="text" name="email" value="Mouse"><br>
<input type="submit" value="Submit">
</form>
</body>
</html>
Can anyone help on that please??

You should use drupal's form api to create the form. Your way is not really "drupalish" way. Then you can define custom content type, with all the fields you need and if form submission handler of your form you can create new nodes in that type with data your form collected.
So google a bit, check some tutorial on form api, and how to make custome form and also on custom content types in drupal. Not that scare as it maybe looks to you right now.
Or, check on webform module that comes with D8 default installation, maybe you can use it instead!

Related

How do I receive the input to my form in my asp.net action?

this seems super simple, yet I'm having trouble figuring it out.
I have a asp.net core mvc application, and I need to use a form to send some input to a specific action.
I have this form:
<div class="panel-body">
<form action="#Url.Action("updateStatus", "Home")">
<textarea class="greyback" id="w3review" name="w3review" rows="4" cols="50"> Update your status...
</textarea>
<br><br>
<input class="input" type="submit" value="Submit">
</form>
</div>
The form invokes the action that I want it to, so far so good, but I of course also need the text that is put into the textfield to be sent along, and that I'm having a bit of trouble with.
I have tried looking at the special razor page stuff for making forms that look like so:
#using (Html.BeginForm(“action”, “controller”))
But I don't quite understand how that works, how I can hold onto my css tags, or how I could actually create a textarea tag with this syntax.
What would be the best way to send along this data to the action that I want?
how I could actually create a textarea tag with this syntax.
You can use the following code:
#Html.TextArea("w3review", "Update your status...", new { #class = "greyback" })
result:
What would be the best way to send along this data to the action that I want?
There is no difference to use html tags or htmlhelper.Htmlhelper will be rendered to html code which is the same with using html tags directly.

Error submit form data from frontend to store in wordpress database using my plugin

I wrote a plugin code. I want to show a custom form using my shortcode made by my plugin at every page I like. The Plugin and the form show correctly but after submitting and processing data to store on the database page not found error occurs. what is the best way to submit data from the frontend to the backend?
// this is my shortcode function code:
<?php
if(isset($_POST['submit_btn']))
{
// inserting data to database process that currently ends with
// Page not found error.
}
?>
<form method="post">
<input type="text" name="name">
<input type="submit" name="submit_btn" value="Store">
</form>
The error happens because of the input name:
I think it is reserved or something like that.
changing that solved my problem.

how to add custom HTML form in drupal

I have HTML5 form with text box and a submit button,like below
<!DOCTYPE html>
<html>
<body>
<form action="/action_page.php">
First name:<br>
<input type="text" name="firstname" value="Mickey">
<br>
Last name:<br>
<input type="text" name="lastname" value="Mouse">
<br><br>
<input type="submit" value="Submit">
</form>
</body>
</html>
and how can I use above html code in drupal??
Well, easiest way for creating forms would be by using webform module. It's easy to use, intuitive, but again powerful:
https://www.drupal.org/project/webform
https://www.drupal.org/docs/8/modules/webform/webform-features
So, my suggestion is to use it and add some CSS if you need to style your form.
Second way, would be by using Drupal's form api. For this you'll have to check on documentation, read some tutorial or similar.Requires some programming skills.
https://www.drupal.org/docs/8/api/form-api/introduction-to-form-api
Third way would be creating totally custom page end-point, where you can literally copy-paste your code as it is:
https://www.drupal.org/docs/8/creating-custom-modules/create-a-custom-page

Drupal WebForm With PinPointe--Avoid Confirmation Page

Our company uses PinPointe for email marketing and we have a Drupal 6 site with several language domains. I have created a web form except I did not create any fields in Drupal. Instead in the node Edit NOT THE NODE WEBFORM EDIT....in the node edit for the body section I added the HTML and the javascript for form. Everything works well and the data is captured to pinpointe. The problem lies in the fact that the page..upon clicking submit..actually redirects to PinPointe where I get a friendly message saying. Thanks for joining. Well I don't want this. I would like to just pop an alert saying thanks and leave the user on the page they were on. I tried this code for using jquery to do the post but it isn't loading and I suspect that's because I need it in the header not the body.
So all I want is to submit the data to pinpointe and not redirect the user. So here is where my limited Drupal knowledge runs out:
If I create the input fields in the node webform then how do I get the form to post to pinpointe?
If I create the fields dynamically in the node body (not node>>webform) I can direct the submission to PinPointe but then how do I stop the redirect?
FWIW here is the jquery I was trying to use but suspect has to go in the header http://jsfiddle.net/4xDFK/4/
FWIW here is the code for the dynamic creation:
<form action="http://na04.mypinpointe.com/...." id="webform-client-form-1375" method="post" onsubmit="return CheckForm257(this);">
<div>
<div id="webform-component-UsrEmail">
<div id="edit-submitted-UsrEmail-wrapper">
<input id="edit-submitted-UsrEmail" name="email" size="30" type="email" />
</div>
</div>
<div class="form-actions form-wrapper" id="edit-actions">
<input class="form-submit" id="edit-submit" name="op" type="submit" value=" " />
</div>
</div>
</form>
Create your custom confirmation page in Drupal. Then set up PinPointe to redirect to this confirmation page.
In the PinPointe form manager, there is a option under the 'Thank you page options' to send a signup user to a custom URL.

ASP.Net using multiple form tag and post them to another page

I don't know it's even possible but I try to achieve to post data from one page to another using the second form.
The problem is I need a form tag for the user interface containing callback panels etc. I want to put a second form with some hidden-field:
<form id="postForm" method="post" action="target.aspx">
<input type="hidden" id="id" />
</form>
I submit the form from javascript with jquery:
$("#id").val(id);
$("#postForm").submit();
Is there a way access the value of the hidden field on the target page?
You should give the hidden field a name attribute:
<input type="hidden" id="id" name="id" />
You'll then be able to use Request.Form in your target page to access the posted data:
string postedId = Request.Form["id"];

Resources