<repo_name>imamrdn/presenceClassA-formProject<file_sep>/data.php
<?php
    echo "<h1>Presensi<h1>";
    $fp = fopen("data.txt", "r");
    echo "<table border=1 width=70%>";
    echo "<tr><th>Nama</th><th>NIM</th><th>Email</th><th>Kelas</th><th>Alamat</th></tr>";
    while ($isi = fgets($fp)){
        $pisah = explode("|", $isi);
        echo "<tr><td>$pisah[0]</td><td>$pisah[1]</td><td>$pisah[2]</td><td>$pisah[3]</td><td>$pisah[4]</td></tr>";
    }
    echo "</tabel>";
?>

<file_sep>/formaction.php
<?php
    if ($_SERVER["REQUEST_METHOD"] == "POST") {
        $name   = $_POST['nama'];
        $nim    = $_POST['nim'];
        $email  = $_POST['email'];
        $class  = $_POST['class'];
        $address= $_POST['address'];
        $enter  = "\n";

        if (!empty($name) && !empty($nim)) {
            if (!empty($email) && !empty($class)) {
                if (!empty($address)){
                    echo "<h1>Presensi Berhasil</h1>";
                    $myfile = fopen("data.txt", "a+");
                    fwrite($myfile, "$name | $nim | $email | $class | $address $enter");
                    fclose($myfile); 
                } else {
                    echo "Data belum lengkap, presensi Anda Gagal";
                }     
            } else {
                echo "Data belum lengkap, presensi Anda Gagal";
            } 
        } else {
            echo "Data belum lengkap, presensi Anda Gagal";
        }

        
    }

    echo "<br><a href='data.php'>Lihat Presensi</a><br>";
    echo "<a href='index.php'>Isi Presensi</a>";
?>
