1. PEMROGRAMAN WEB. 05 – HTML Form and Introduction to PHP. Andi WRE.
Here comes your footer. Web Programming – HTML Form and. Introduction to ...
PEMROGRAMAN WEB 05 – HTML Form and Introduction to PHP
Andi WRE
HTML Form Media for user to input data Allow the user to send data to web sites Example : registration, send messages, post comment, post video, etc. Need web scripting server side for data processing Example : PHP, ASP, JSP, etc
Web Programming – HTML Form and Here comes your footer Introduction to PHP
1
Web Programming – HTML Form and Here comes your footer Introduction to PHP
HTML Form
draws a box around the related elements defines a caption for the element
Attribute ...
Value
Description
name
Text
Specifies the name of a form
method
GET/POST
Specifies the HTTP method to use when sending form-data
action
URL/nama file
Specifies where to send the formdata when a form is submitted
Web Programming – HTML Form and Here comes your footer Introduction to PHP
2
Method GET/POST GET Useful for form submissions where a user want to bookmark the result Display the form contents from the user Have a limit to how much data you can place in a URL (varies between browsers) Never use the "get" method to pass sensitive information! http://localhost/form_login/proses_login.php?uname=nama_user&pwd=pass_user
POST More robust and secure than GET Hide the form contents from the user Form submissions with the "post" method cannot be bookmarked Not have size limitations http://localhost/form_login/proses_login.php Web Programming – HTML Form and Here comes your footer Introduction to PHP
HTML Form - Input Used to select user information Not require a closing tag for HTML An input field can vary in many ways, depending on the type attribute the tag requires a name, the name of the tag allows the programmer to work with the data from the control Attribute
Value
Description
name
Text
Specifies the name of the input tag
type
Type
Specifies the type of element
value
Text
The default value
Web Programming – HTML Form and Here comes your footer Introduction to PHP
3
HTML Form - Input Type Text
Define a single-line text field that a user can enter text into Attribute
Value
Description
size
Number
Width text field
maxlength
Text
Character limit
Nama :
Web Programming – HTML Form and Here comes your footer Introduction to PHP
HTML Form - Input Type Password
Define a password field (characters are masked) Attribute
Value
Description
size
Number
Width text field
maxlength
Text
Character limit
Password :
Type Submit
Define a submit button a button that sends the form data to the action. Anggur
Web Programming – HTML Form and Here comes your footer Introduction to PHP
5
HTML Form - Input Type Radio
a series of controls from which the user can select one choice. Jenis Kelamin : Laki-Laki
Web Programming – HTML Form and Here comes your footer Introduction to PHP
HTML Form - Input Type Hidden
Define a hidden field (not visible to a user). A hidden field often store a default value, or can have its value changed by a JavaScript.
Type File
Allows the user to browse to a file on their machine for submission to the web site. Gambar :
Web Programming – HTML Form and Here comes your footer Introduction to PHP
HTML Form – Drop Down List Drop-down lists are a good method to deliver a large range of choices without taking a lot of screen space. A drop-down list allows multiple selections ... Januari Februari Maret April Mei Juni
Web Programming – HTML Form and Here comes your footer Introduction to PHP
7
HTML Form – Option Group The is used to group related options in a drop-down list. If you have a long list of options, groups of related options are easier to handle for a user. Volvo Saab Mercedes Audi
Web Programming – HTML Form and Here comes your footer Introduction to PHP
HTML Form - Textarea A text area can hold an unlimited number of characters, and the text renders in a fixed-width font (usually Courier). The size of a text area is specified by the cols and rows attributes. ... Attribute
Value
Description
rows
Number
Specifies the visible width of a text area
cols
Number
Specifies the visible number of lines in a text area
Berikan komentar anda
Web Programming – HTML Form and Here comes your footer Introduction to PHP
8
Introduction to PHP PHP : Hypertext Preprocessor A server-side scripting language Scripts are executed on the server Supports many databases (MySQL, Informix, Oracle, Sybase, Solid, PostgreSQL, Generic ODBC, etc.) An open source software
Web Programming – HTML Form and Here comes your footer Introduction to PHP
XAMPP Local Web Server Open Source Interpreter PHP script and MySQL database 2 type of MySQL : - MySQL - MySQL with web server XAMPP (PHPMyAdmin)
Web Programming – HTML Form and Here comes your footer Introduction to PHP
9
XAMPP Access XAMPP from browser http://localhost/xampp/
Web Programming – HTML Form and Here comes your footer Introduction to PHP
PHP File PHP code is not displayed when user view source from browser Save PHP File in directory XAMPP/htdocs/directory_name How to access PHP or HTML page in browser? http://localhost/directory_name/file_name example : http://localhost/form_login/login.php
Web Programming – HTML Form and Here comes your footer Introduction to PHP
10
PHP Syntax A PHP script always starts with . A PHP script can be placed anywhere in the document. A PHP file must have a .php extension.
output text with PHP
Each code line in PHP must end with a semicolon. The semicolon is a separator and is used to distinguish one set of instructions from another.
Web Programming – HTML Form and Here comes your footer Introduction to PHP
PHP Variables Rules for PHP variable names: - Variables in PHP starts with a $ sign, followed by the name of the variable - The variable name must begin with a letter or the underscore character - A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ ) - A variable name should not contain spaces - Variable names are case sensitive (y and Y are two different variables) Example :
Web Programming – HTML Form and Here comes your footer Introduction to PHP
11
Comments in PHP In PHP, we use // to make a one-line comment or /* and */ to make a comment block
Web Programming – HTML Form and Here comes your footer Introduction to PHP
The Concatenation Operator The concatenation operator (.) is used to put two string values together.
Web Programming – HTML Form and Here comes your footer Introduction to PHP
12
HTML in PHP
Web Programming – HTML Form and Here comes your footer Introduction to PHP
PHP Operators Arithmetic Operators +
-
*
/
%
++
--
Assignment Operators =
+=
-=
*=
/=
%=
Comparison Operators ==
!=
>
>=