F ORM Bayu Priyambadha, S.Kom
F ORM Form is the interface (user interface) for users to communicate with the application system. Each posted data from a user called the request and any results of processing by the server is called a response.
HTML F ORM In HTML, we use sintax : Form tag has attribute : Action for define destination file Method for define method used on sending request Method : Get Post Head Put Link Unlink Option Delete Trace Connect
G ET & P OST M ETHOD
R EAD S ENT D ATA Read data with Get method : Use $_GET[“name”] Read data with Post method : Use $_POST[“name”] Ex : <? echo $_GET[“data1”]; echo $_GET[“data2”]; ?> <? echo $_POST[“data1”]; echo $_POST[“data2”]; ?>
F ORM E LEMENTS There are several components that can be used in the field on the form include:, For this type of input in the form of field filling one row, For this type of input in the form of multi-row &, For the type of input options (combo box) Every input element have attribute named “name”, for define the name of element
I NPUT E LEMENT Input tag has many type : For text type For submit form For reset form For password type For file type For checkbox type For radio button type For hidden input
E XAMPLE Form.php Form.php Proses.php <?php echo $_GET[“nama”]; ?> Proses.php <?php echo $_GET[“nama”]; ?>
T RY T HIS !!! Buat sebuah form dengan inputan : Berlabel “panjang”, bertipe teks Berlabel “lebar”, bertipe teks Tombol submit Buat halaman penerima dengan spesifikasi : Menerima kiriman “panjang”, diisikan pada variabel “p”, Menerima kiriman “lebar”, diisikan pada variabel “l”, “p” dan “l” dikalikan, hasilnya dimasukan dalam variabel “hasil”, Variabel “hasil” dicetak.