Exercise
Exercise
Exercise
php
<?php
?>
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Welcome To My Page</title>
</head>
<body>
<form name="form1" method="post" action="page2.php">
<div class="mb-3">
<label for="nama" class="form-label">Nama</label>
<input type="text" class="form-control" name="nama" aria-
describedby="emailHelp">
</div>
<div class="mb-3">
<label for="nokp" class="form-label">No. KP</label>
<input type="text" class="form-control" name="nokp">
</div>
<button type="submit" class="btn btn-primary">Hantar</button>
</form>
</html>
Page2.php
<?php
session_start();
$nama = $_POST['nama'];
$nokp = $_POST['nokp'];
?>
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Page 2</title>
</head>
<body>
<form name="page2" method="post" action="page3.php">
<table class="table">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Nama</th>
<th scope="col">No KP</th>
<th scope="col">Bil. Subjek</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">1</th>
<td><input type="text" class="form-control" name="nama[]" aria-
describedby="emailHelp"></td>
<td><input type="text" class="form-control" name="nokp[]" aria-
describedby="emailHelp"></td>
<td><input type="text" class="form-control" name="bil[]" aria-
describedby="emailHelp"></td>
</tr>
<tr>
<th scope="row">2</th>
<td><input type="text" class="form-control" name="nama[]" aria-
describedby="emailHelp"></td>
<td><input type="text" class="form-control" name="nokp[]" aria-
describedby="emailHelp"></td>
<td><input type="text" class="form-control" name="bil[]" aria-
describedby="emailHelp"></td>
</tr>
<tr>
<th scope="row">3</th>
<td><input type="text" class="form-control" name="nama[]" aria-
describedby="emailHelp"></td>
<td><input type="text" class="form-control" name="nokp[]" aria-
describedby="emailHelp"></td>
<td><input type="text" class="form-control" name="bil[]" aria-
describedby="emailHelp"></td>
</tr>
<tr>
<th scope="row">4</th>
<td><input type="text" class="form-control" name="nama[]" aria-
describedby="emailHelp"></td>
<td><input type="text" class="form-control" name="nokp[]" aria-
describedby="emailHelp"></td>
<td><input type="text" class="form-control" name="bil[]" aria-
describedby="emailHelp"></td>
</tr>
<tr>
<th scope="row">5</th>
<td><input type="text" class="form-control" name="nama[]" aria-
describedby="emailHelp"></td>
<td><input type="text" class="form-control" name="nokp[]" aria-
describedby="emailHelp"></td>
<td><input type="text" class="form-control" name="bil[]" aria-
describedby="emailHelp"></td>
</tr>
</tbody>
</table>
<center><button type="submit" class="btn btn-primary">Kira</button></center>
</form>
</html>
Page3.php
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Page 3</title>
</head>
<body>
<table class="table">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Nama</th>
<th scope="col">No KP</th>
<th scope="col">Bil. Subjek Diambil</th>
</tr>
</thead>
<tbody>
<?php
$nama = $_POST['nama'];
$nokp = $_POST['nokp'];
$bil = ($_POST['bil']);
$count=1;
$total=0;
$jumbyr=0;
<tr>
<th scope="row"><?php print $count; ?></th>
<td><?php print $nama[$id]; ?></td>
<td><?php print $nokp[$id];?></td>
<td><?php print $bil[$id];?></td>
</tr>
<?php
++$count;
}
?>
</tbody>
</table>
<?php
function cetak($tot)
{
echo "Jumlah keseluruhan bayaran adalah RM : $tot";
}
?>
</html>