Form is a input data in web page. And then data will be sent to server and stored in database and then next will be processed. Form have attribute methode which is use to determine how to sent a data. there are 2 method, they are POST and GET. Below is a basic script of form.
<form action="url" method="post">
....
form contents
....
</form>
Method in Form there are 2, they are:
1. GET
Get is method which is possible for we write a data via address bar or URI (Uniform Resource Identifier) on browser. Let's see example below.
<html>
<head>
<title>Form</title>
</head>
<body>
<form action="process_get.php" method="get">
<Pre>
Name :<input type="text" name="nama"/>
Address:<textarea name="address"></textarea>
</pre>
<input type="submit" value="Send"> </form>
</body>
</html>
<html>
<head>
<title>Form</title>
</head>
<body>
<form action="process_get.php" method="get">
<Pre>
Name :<input type="text" name="nama"/>
Address:<textarea name="address"></textarea>
</pre>
<input type="submit" value="Send"> </form>
</body>
</html>
For display script above we must typing text in form_get.php. Below is how to fill and send the data in the form. Let's see...
Click Send button to send data. Below is output of data has been sent.
Below is output of changing data above.
We can add data in address bar with way typing character & followed index of data and then value of data. Below is example.
To display data that is more beautiful Let's see script below.
<?php
echo "Name : ".$_GET['nama'];
echo "<br />";
echo "Address : ".$_GET['address'];
?>
Below is output of script above.
Below is brief explanation about script above.
To catch the value or data of the form, we can use the $ _GET and followed with name of element , see picture above, element <input type="text"> name="nama"/> has a name "nama" so we can catch the name like $_GET['nama'].
Read more about Form click here to Method POST in PHP and Form HTML Part 2.
No comments:
Post a Comment