100 likes | 249 Views
Form. Bayu Priyambadha, S.Kom. Form. 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 Form. In HTML, we use sintax :
E N D
Form Bayu Priyambadha, S.Kom
Form • 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 Form • In HTML, we use sintax : <form></form> • 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
Get & Post Method • Get is used to send data by request web browser to add data to url • Separate main url and data with “?”, • Separate every data with “&” www.someurl.com/this.php?data1=one&data2=two • Post is used to send data without request web browser to add data to url
Read Sent Data • 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”]; ?>
Form Elements • There are several components that can be used in the field on the form include: • <input>, For this type of input in the form of field filling one row • <textarea>, For this type of input in the form of multi-row • <select> & <option>, For the type of input options (combo box) • Every input element have attribute named “name”, for define the name of element
Input Element • Input tag has many type : • <input type="text" /> For text type • <input type="submit" /> For submit form • <input type="reset" /> For reset form • <input type="password" /> For password type • <input type="file" /> For file type • <input type="checkbox" /> For checkbox type • <input type="radio" /> For radio button type • <input type="hidden" /> For hidden input
Example Form.php <form action=”proses.php” method=”GET”> <input type=”text” name=”nama”> <input type=”submit” value=”Go”> </form> Proses.php <?php echo $_GET[“nama”]; ?>
Try This!!! • 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.