In using of checkbox, we can choose more of one choice. Below is example from order form of foods by using checkbox. Save with file name is in-checkbox.php (in checkbox = input checkbox).
<head>
<title>Checkbox</title>
</head>
<body bgcolor="yellow">
<FORM ACTION="pro-checkbox.php" METHOD="POST" NAME="input">
<h3>Pesan Makanan disini :</h3>
<input type="checkbox" name="menu1" value="Bakso" checked> Bakso<br>
<input type="checkbox" name="menu2" value="Mie Ayam"> Mie Ayam<br>
<input type="checkbox" name="menu3" value="Soto Ayam"> Soto Ayam<br>
<input type="checkbox" name="menu4" value="Soto Babat"> Soto Babat<br>
<input type="submit" name="pilih" value="pilih">
</FORM>
</body>
</html>
Input Form |
For process file below, save with file name pro-checkbox.php (pro-checkbox = process checkbox)
<body bgcolor="yellow"> // Tag body need not to write, writer use the tag just
</body> // page browser looked more interesting
<?php
if (isset($_POST['pilih'])) {
echo "Makanan pesanan kamu :<br>";
if (isset($_POST['menu1'])) {
echo "*" . $_POST['menu1'] . "<br>";
}
if (isset($_POST['menu2'])) {
echo "* " . $_POST['menu2'] . "<br>";
}
if (isset($_POST['menu3'])) {
echo "* " . $_POST['menu3'] . "<br>";
}
if (isset($_POST['menu4'])) {
echo "* " . $_POST['menu4'] . "<br>";
}
}
?>
Process Form |
0 comments:
Post a Comment