HTML form

Posted on 2014-07-16
Last Modified: 2014-07-23
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="">
 <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?
Question by:SvenIA
    LVL 52

    Expert Comment

    by:Scott Fell, EE MVE
    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 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.
    LVL 7

    Author Comment

    And what if people have to logon to the website first, before being able to send the form.... Is it save from spamming?
    LVL 52

    Accepted Solution

    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.
    LVL 16

    Assisted Solution

    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>
    if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $q1 = $_POST['q1'];
    $q2 = $_POST['q2'];
                            $recipient = "";
    			$subject = "Contact Form - My Form";
    			$msg = "Question 1: $q1\n\n";
    			$msg .= "Question 2: $q2\n\n";
    			mail("$recipient", "$subject", "$msg", "");
    			//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.
    LVL 7

    Author Comment

    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?
    LVL 16

    Expert Comment

    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.
    LVL 7

    Author Closing Comment

    Thanks. I used a Wordpress plugin to create forms. I bought Visual Form Builder PRO.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Suggested Solutions

    Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
    Do you want to insert HTML5 video into your site? This is the tutorial how to do so. What are the main advantages of HTML5 video? 1) Have good compression, good image quality, and low decode processor use. 2) It is royalty-free 3) It is easi…
    In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now