Академический Документы
Профессиональный Документы
Культура Документы
• Method
The form method determines how the form input data is sent
and processed. There are 2 types of methods: POST and GET
• Action
Action form determines the form input data processing file. If
this action is left blank (action = "") then the form input data
processing is done on the same page. So the form and processor
pages can be separated or put together
• Submit button
The button that functions as a triggers data transmission from
the form to the processor.
The ways to handle Form and Form
Action
• Combined between forms and form action
The input form and form action are carried out on the same page. This
way, the action attribute is emptied (action = "")
• The captured data comes from the URL, so the data can be seen in
the URL
• The URL should have a length below 2000 characters
• As a limiting variable is &
• The GET method is used when the data is sent a little.
• This method uses $ _GET to process data.
• Data sent with this method will appear in the URL in the browser
address bar which is not safe for sensitive data (such as passwords).
GET
• In the URL, when searching for 'Learn PHP', the browser will send 5
variables to Google. To capture the contents of this variable, Google
will capture the GET method.
GET
$q = $_GET['q'];
$oq = $_GET['oq'];
$aqs = $_GET['aqs'];
$sourceid = $_GET['sourceid'];
$ie = $_GET['ie'];
GET
• If open and click the submit button without entering a name and
address, then the Address Bar will form a ur:
: http://localhost/latihan/get.php?nama=&alamat=
• If entered: nama=John Doe dan alamat=Bandung, then the URL that
formed is:
http://localhost/latihan/get.php?nama=John+Doe&alamat=Bandung
Pay attention to the writing of the name above, every time there is a
space, it will be replaced with a plus sign (+) in the Addres Bar. The
question is, what if the added sign (+) is inserted, then the result will be
http://localhost/blog/get.php?nama=%2B&alamat=%2B.
Automatically the + sign is changed to% 2B, because the sign (+) in the
Address Bar is known as a space.
Contoh coding Method Get
<html>
<head><title>Pengolahan form</title></head>
<body>
<form action=“” method=“get” name=“myform”>
Nama : <input type=“text” name=“nama” size=“25”>
<input type=“submit” value=“simpan” name=“simpan”>
</form>
<?php
If (isset($_GET[‘simpan’]))
{
$nama=$_GET[‘nama’];
echo “Nama Anda : <b>$nama</b>”;
}
?>
</body>
</html>
John Doe
/Form01.php?nama=John+Doe&simpan=simpan
GET
POST
Example: (Action file separated from Form
File form (form.html):
<html>
<head><title>Pengolahan form</title></head>
<body>
<form action=“simpan.php” method=“post” name=“myform”>
Nama Pelanggan : <input type=“text” name=“nama” size=“25”
placeholder=“Nama Pelanggan”><br/>
Alamat Pelanggan : <textarea name="alamat" placeholder="Alamat
Pelanggan" cols="23" rows="5"></textarea><br/>
<input type=“submit” value=“Simpan” name=“Simpan”>
</form>
</body>
</html>
Contoh coding FORM
<?php
If (isset($_POST[‘Simpan’]))
{
$nama=$_POST[‘nama’];
echo “Nama Anda : <b>$nama</b>”;
}
?>
PHP AND DATABASE
koneksi.php
simpan.php
Hasil simpan.php (action file)
tampil.php
Hasil tampil.php