[Last Call] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 206
  • Last Modified:

HTML form

Hi Folks,

I want to create a simple HTML / CSS website where people can fill in soccer game scores. Here is an example of the code I want to use;

<form method="post" action="mailto:myemailadres@domain.com">
 <em>Question 1:</em> <input type="text" size="20" maxlength="40" name="Question 1"><br>
 <input type="submit" value="Send">

Open in new window

The send button opens up the e-mail client on the computer. Is there a way to create a send button that sends the form immediately?

Is this the best way to create a form using just HTML? Are there other ways to create a form with a simple script, like with JAVA Script or something?
  • 3
  • 2
  • 2
2 Solutions
Scott Fell, EE MVEDeveloperCommented:
It is actually not a very good way of sending email besides the fact your email will just end up getting spammed.

You will want to do this with a server side language such as php or asp.  Or you can use an api for something like mandrill  https://mandrillapp.com/docs/integrations.html with different types of integrations.  If you can use something other than javascript, that would be best, but the js being the only choice will work.
SvenIAAuthor Commented:
And what if people have to logon to the website first, before being able to send the form.... Is it save from spamming?
Scott Fell, EE MVEDeveloperCommented:
If you are going to do that, just use a link with your email.

If you have people logging in, that means you have some type of server side code like php or asp.  Use that to send your mail.  The form should post to a processing page and the processing page will send out the mail and redirect to a thank you page.
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Forms are two parts:
1. Create the form
2. Process the form

If your server supports PHP, here is a simple mail script that will get you started.

<!doctype html>
$q1 = $_POST['q1'];
$q2 = $_POST['q2'];

                        $recipient = "myEmailAddress@domain.com";
			$subject = "Contact Form - My Form";
			$msg = "Question 1: $q1\n\n";
			$msg .= "Question 2: $q2\n\n";

			mail("$recipient", "$subject", "$msg", "From:contact@domain.com");
			//echo mysql_error();
			$reply = "Thank you $name for contacting. Your message has been sent!";


<form action="" method="post">
Question1 <input type="text" name="q1"><br>
Question2 <input type="text" name="q2"><br>
<input type="submit" name="submit" value="Submit">


Open in new window

If you do not use a server to process your form, your website will rely on the visitors local mail client to send the mail. The problem is that many people use web mail such as gmail and yahoo; they will not be able to process your form properly.
SvenIAAuthor Commented:
Thanks rbudj

What does the 'submit' button do in your script? What if I do have a mailserver, where can I specify it in the script?
When the submit button is pressed. the page "refreshes" itself. It takes the form values and places them into variables using the php script. Those values are then sent using the mail() function.
SvenIAAuthor Commented:
Thanks. I used a Wordpress plugin to create forms. I bought Visual Form Builder PRO.

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now