How do I make a simple email form submission in HTML? - html

I tried w3schools but it didn't help and I tried other websites too. I just wanna make a short html script that sends an email to an email address, but I keep reloading my email inbox and nothing comes up. Can you help?
<form action="MAILTO:MY_EMAIL#yahoo.com" method="post" enctype="text/plain">
<input type="text" name="email" value="Email">
<input type="text" name="message" value="Message">
<input value="Submit" type="submit">
</form>

You need to use a server side script here. HTML alone won't help you here. HTML is just the frontend logic. You need some script on backend that accepts this data you submit and actually sends out an email. To take the example in PHP, assuming u have the server set up and all or that your shared
<form action="sendmail.php" method="post" enctype="text/plain">
<input type="text" name="email" value="Email">
<input type="text" name="message" value="Message">
<input value="Submit" type="submit">
</form>
sendmail.php
$email=$_POST['email'];
$message=json_encode($_POST);
$receiver="MY_EMAIL#yahoo.com";
$mailer="mailer#myservice.com";
mail($email,"Message for enquiry or whatever",$message, array("from"=>$mailer));

There were, at some point, browsers that supported forms of this type. However, they're all gone now -- you will need a server-side script to send email. It's impossible to do using HTML alone.

You are confusing a few things.
When you Submit a form, it goes from the client (browser) to your server, which acts upon it. The form action needs to be a URL which handles the request. The mailto: URI scheme is not a valid action to use.
You have two choices:
You can create a mailto: link like this:
Send email
which will open your default email client,
OR
You can put a URL corresponding to an end point on your server, something like
form action="/send/mail"...
and have your server send the email

I believe the easiest way to do this is using a service like Zapier or IFTTT. Both of them offer a way to create Zaps/Applets that can send an email when you post to a specific url.
This is what configuration would look like in IFTTT and Zapier .
IFTTT is simpler to setup, Zapier has more options, like sending to more than one emails. I believe IFTTT only lets you send to your account's email.

Related

How to specify an URL after the submission of a form?

This is hypothetical but I wonder if this is possible.
Let's say I have a single input form on a page of my website that collects emails.
<form>
<label for="email">Enter your email:</label>
<input type="email" id="email" name="email">
<input type="submit">
</form>
Once the button is clicked, I use a third-party service (say Zapier) to get a unique & public URL that is external to my website (say a link to a newly created Trello board).
Pseudocode
When someone submit his email in my form
Zapier is triggered and creates a new public Trello board
Zapier posts back the URL of the Trello board
The person is redirected to the Trello board
Is there a way to perform this?
I'm not familiar with redirections yet. Maybe there's a way to redirect temporarily (302?) until the Trello URL posted by Zapier is catched, leading to the right redirection.
If it's not feasible, how would you handle this?
Thanks for your help!
It is possible. Process the email address on the server side: Trigger the Zapier board creation and get the URL back from them. Then redirect the user to his new Trello board. For example, in PHP you execute header('Location: ' . $trelloBoardURL);.

How to send email with form submission on Netlify?

I am making a website for a restaurant and I want to make a reservation form where people would enter their name, time of reservation, etc. And when they submit this form I want to send an email to my email.
I know there is a service called Zapier which gives you the ability to do that, but I am looking for something free (in this case Zapier free tier has only 100 tasks per month which may not be enough).
I would want it to look something like this:
<form>
<input type="text" placeholder="Your name" />
<!-- and some other inputs -->
<input type="submit" value="Send" />
<!-- after this send an email with entered information -->
</form>
If you're hosting your site on Netlify you can use their feature "Netlify forms" which is free and easy to integrate (just add a custom "netlify" attribute to your HTML form element). Here are their docs:https://docs.netlify.com/forms/setup/#html-forms
Netlify also helps you with spam/robot protection before (e.g. via a so called "honeypot" field) and after submit (e.g. via a tool called "akismet").
Then you can set up email notifications, which will send you the data of the submitted form to your email inbox of choice. Here are their docs: https://docs.netlify.com/forms/notifications/
Instead of using Netlify or Zapier, you might just want to use getsimpleform.com as the form endpoint. As far as I know, the service is free and sends you an email on form submission.

Send an e-mail automatically with data from a form

I need some advice in order to generate automatically an email that sends the answers from a form to my email adress.
We used the mailto method included in the html API, but it just opens a mail window, we would like to trigger the sending of the email by clicking on the validation button of the form.
<form>
<input type="checkbox" id="item1" name="interest" value="item1">
<label for="coding">Male</label>
<br/>
<input type="checkbox" id="item2" name="interest" value="item2">
<label for="coding">Female</label>
<br/>
<input type="submit" name="Submit" value="Submit">
</form>
Thank you for your time !
This is not possible with client-side code alone. If it were possible, then any website could use every visitor's browser to send any email to any email address. That would be a spammer's dream.
You must send the data over HTTP to a server (this is most easily done by using an HTTP URL in the action attribute, but you could also look to JavaScript (Ajax)) and then use server-side code to send it.
The specifics of the server-side code will depend on your choice of programming language.
You might also seek out a third party service which will provide a pre-existing HTTP endpoint hosted on their servers which you can use.

How to send a post request to GTMetrix

I want my users to write his website on my site and then be sent to gtmetrix.com to start a new test, but without needing to write his website again.
I am trying with this:
<form method="post" action="https://gtmetrix.com/analyze.html">
<input type="text" placeholder="Enter your Website URL"></input>
<input type="submit">CHECK IT</input>
</form>
But i get a
Analysis Error
You tried to analyze an invalid/malformed URL
What i am doing wrong? is possible to do this?
It seems they require the url in the form data field called url.
You must use the following input tag:
<input type="url" name="url" value="" placeholder="Enter your website URL" maxlength="1024" autofocus="" required="">
Also, they could be blocking external referrers. But first try adding the name attribute.
First of all, I don't know if that website allows you to submit that form from external websites. Make sure that's possible!
Seccond of all, you are trying to sent a form without setting the name of the input field. The resource that receives your request don't know anything to do with it.
If you want to analyse websites on your own website, search for services that provide APIs for using it external.
I am not familiar with gtmetrix, but you need to set the name attribute on your input to send it with the request.

Validate username as input is provided to textbox in jsp

I have a jsp form in which a user can signup by entering username and password. I have to check dynamically whether the username exists in mysql database as the username is typed into the text box. Here is a sample code:
<html>
<head>Sample Signup</head>
<body>
<form action="updatedb.jsp" method="post">
Username : <input type="text" name="uname">
<br>
Password : <input type="text" name="upass">
<br>
<input type="submit" value="signup">
</form>
</body>
</html>
I am new to jsp so an elaborated answer will be more helpful. If i missed any other important info, ask me right away.
Java cannot respond to the client-side methods like onChange (not directly). Those methods call Javascript. Javascript is not actually related in any way to Java; its only called that because it uses the bracket-style syntax for functions as opposed to VB-style syntax. The only way to involve Java itself in the client-side methods would be to use Javascript to send an Ajax request to a JSP/Servlet and receive a response back. The simplest way to send an Ajax request in Javascript is with jquery (a javascript library).