How to make HTML Form with PHP for beginners

 How to make HTML Form with PHP for beginners 





 Make a HTML Form with PHP 

  • The user's input is collected using forms, which are then sent to the web server for processing. An HTML tag called "form" includes graphical user interface elements including input boxes, check boxes, radio buttons, and more.
  • The form is specified by the form> element. Form components like input> are used to define /form> tags and GUI objects. Depending on the bytes properties, the input >element can be shown in a number of different ways..
How to make HTML Form with PHP for beginners


Syntax <form>
.
form elements
</form>

Some basic HTML Form Tags given below

Tag                        Description
<form>                It specifies an HTML form for user-side input.
<input>                It defines an input control
<textarea>           There is a multi-line input control defined.
<label>                It defines a label for an input element
<fieldset>            It groups the related elements in a form
<legend>             IThe caption for a "fieldset" element is defined by t.
<select>               It defines  drop-dwon
<optgroup>          It describes a collection of connected drop-down menu options.
<option>              It defines an option in a drop-down lis.
<button>              this defines a clickable button.

HTML Input Tags

Type                                       Description
<input type="text">            Defines a one line text input field
<input type="rdio">           what a radio button is (For selecting one from multiple options)
<input type="checkbox">   defines a checkbox() for multiple choice selection.
<input type="submit">       Defines a submit button (For submitting the HTML form)

Action Attribute

The action that will be taken when the form is submitted is specified by the action attribute. Normally, when a user clicks the submit button on a form, the form's data is delivered to a server-side web page. The action is set to the current page if the action attribute is absent.

Target Attribute

The destination attribute indicates whether the submitted result will open in the current window, a frame, or a new browser tab. The form will be submitted in the current window if the default value is "_self." Use the value "_blank" to make the form result open in a new browser tab: Action: actionpage.php; target: _blank; form

Method Attrubute

The HTTP method (GET or POST) to be used when submitting the form data is specified by the method property.

EX:<form action="actionpage.php" method="get">
or <form action="actionpage.php" method="post">

Here is the list of <form > attribute

Attribute                             Description 

accept-charset                      discloses the eharset used in the form that was submitted (default: the                                                     charset)
action                                    Specifies an address (url) where to submit the form (default : the                                                               submitting page )
autocomplete                       Decides whether the form should be autocompleted by the browser                                                             (default:on)

enctype                                  Specifies the encoding of the submitted data (default: is url-encoded).

method                                  Specifies the HTTP method used when submitting the form (default                                                          GET)
name                                     this Specifies a name used to identify the form

novalidate                              It Specifies that the browser should not validate the form.

target                                      this Specifies the target of the address in the action attribute                                                              

POST                                                       

has no restriction on the values' length because they are submitted via the HTTP body

Its slower than the php GET method because it takes longer to encapsulate the Php POST values in the HTTP body.

It Supports many different data types such as string, numeric and binary.

Results cannot be book marked

GET

limits the length of the values to 255 characters, on average. this is due to the values being shown in the URl. Please take note that the browser determines the maximum number of characters.

due to the ease of attaching the values to the URL, performs well compared to the POSt approach.

Supports nyl string data types because the values are displayed in the URL.

Results can be book marked due to the visibility of the values in the URL.

Capturing Form Data with PHP

The following superglobal variables can be used to get the value of a specific form field. These variables are accessible throughout the whole scope of a script.

Superglobal                     Description

$_GET                              Contains a list of each field's names and values that were sent by a form using                                           the get method (i.e, via the URL parameters).
$-POST                             Contains a list of all the field names and values by a form using the post                                                  method (data will not visible in the URL)
$_ REQUEST                   contains the values of both the $_GET and $_POST variables as well as the                                              value of the $_COOKIE superglobal variable 

 

Thanks for visiting our website please feel free to add your comment below so that we can optimise out content quality


Post a Comment

Previous Post Next Post