Exampler.org SAS PYTHON HTML
HTML Home
HTML Table
HTML Form
HTML Button
HTML Checkbox
HTML Select
HTML Contact Form

HTML Buttons;

What is it?

Syntax:

  • Submit: <input type='submit' value='submit'>
  • Radial: <input type='radial' >
  • Checkboxes: < input type='check' >
  • ComboBoxes:< select > <option value='option 1'> Option 1 </option>
  • Date: < input type='date' >


 Basic Input Form Example :



<form action='transmitmydata.php' method='post' >

     <input type='text' placeholder='Enter Phone Number Here' name='phone' >

     <input type='button' value='Submit'>

</form>





What's happening in the script above?

  • We've got a form with 1 text input, and 1 submit button
  • The form has two additional elements "action='transmitmydata.php" and "method='post'"
  • The action element is where the data is going to be sent when someone clicks the button
  • The method can either be Post or Get ("post" passes the information invisibly, "Get" passes the information visibly in the browser)
  • When a user clicks the button, the form has been instructed to send the data in the text box which we've named "phone" to transmitmydata.php
  • transmitmydata.php will read that information and do something with it, like send an email, text message or store the information in a database.


Example Output:






 transmitmydata.php:



<?php

$phone_number = $_POST(phone);
$email_subject = "Customer Phone Number";
mail("sales@mystore.com" , $email_subject , $phone_number);

?>



What's happening in the script above?

  • The Transmitmydata.php reads the form data specifically the POST data coming from the phone field.
  • The data from the phone field got passed to the PHP script which then combined it with the subject of an email
  • then used the mail() function in PHP to fire off an email to sales@mystore.com
  • Unlike HTML, CSS and JavaScript that all run locally (e.g. on your computer alone), PHP sits on a server
  • Many common website providers like hostgator.com offer PHP out of the box so you could copy that code, save it as transmitmydata.php
  • Then upload both the form and transmitmydata.php to your websiteand it should run.




See also; HTML Form

See also; HTML Buttons

See also; HTML Iframe




Connect via LinkedIn

Kevin Regan

Have an article, idea, found a typo, want to contribute? Shoot me an email Here