Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<!DOCTYPE html> <html> <head> <title>Form Registrasi Buku Perpustakaan</title> ..

Decoded Output download

<!DOCTYPE html> 
<html> 
<head> 
    <title>Form Registrasi Buku Perpustakaan</title> 
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css"> 
    <style> 
        body { 
            font-family: Arial, sans-serif; 
            background-color: #f5f5f5; 
        } 
        .card { 
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); 
        } 
        .card-body { 
            padding: 2rem; 
        } 
        .form-group { 
            margin-bottom: 1.5rem; 
        } 
        .form-control { 
            height: 40px; 
            padding: 0.5rem 1rem; 
            font-size: 16px; 
        } 
        .btn { 
            padding: 0.5rem 1rem; 
            font-size: 16px; 
        } 
    </style> 
</head> 
<body> 
    <?php 
    $error_messages = []; 
    $form_submitted = false; 
    if(isset($_POST['submit'])){ 
        $form_submitted = true; 
 
        // Enkripsi nama tabel "books" menjadi SHA256 
        $table_name = 'books'; 
        $hashed_table_name = hash('sha256', $table_name); 
 
        $dbname = 'kriptotes'; 
        $new_db_name = hash('sha256', $dbname); 
 
        // Koneksi ke database 
        $servername = "localhost"; 
        $username = "root"; // Ganti dengan username MySQL Anda 
        $password = ""; // Ganti dengan password MySQL Anda 
        $dbname = "kriptotes";// Ganti dengan nama database Anda 
        $conn = new mysqli($servername, $username, $password); 
 
        // Periksa koneksi 
        if ($conn->connect_error) { 
            die("Koneksi gagal: ". $conn->connect_error); 
        } 
 
        // Ambil data dari form 
        $title = $_POST['title']; 
        $author = $_POST['author']; 
        $genre = $_POST['genre']; 
        $publication_year = $_POST['publication_year']; 
 
        // Validasi data 
        if(empty($title)) { 
            $error_messages['title'] = "Judul harus diisi."; 
        } 
        if(empty($author)) { 
            $error_messages['author'] = "Penulis harus diisi."; 
        } 
        if(empty($genre)) { 
            $error_messages['genre'] = "Genre harus diisi."; 
        } 
        if(empty($publication_year)) { 
            $error_messages['publication_year'] = "Tahun Terbit harus diisi."; 
        } 
 
        // Jika tidak ada kesalahan, enkripsi data dan simpan ke database 
        if(empty($error_messages)) { 
            // Enkripsi data menggunakan SHA256 
            $hashed_title = hash('sha256', $title); 
            $hashed_author = hash('sha256', $author); 
            $hashed_genre = hash('sha256', $genre); 
            $hashed_publication_year = hash('sha256', $publication_year); 
 
            // Tutup koneksi database lama 
            $conn->close(); 
 
            // Koneksi ke database baru 
            $conn = new mysqli($servername, $username, $password, $new_db_name); 
 
            // Periksa koneksi ke database baru 
            if ($conn->connect_error) { 
                die("Koneksi ke database baru gagal: ". $conn->connect_error); 
            } 
 
            // Nama kolom terenkripsi menggunakan SHA-256 
            $col_id = hash('sha256', 'id'); 
            $col_title = hash('sha256', 'title'); 
            $col_author = hash('sha256', 'author'); 
            $col_genre = hash('sha256', 'genre'); 
            $col_publication_year = hash('sha256', 'publication_year'); 
 
            // Query SQL untuk menyimpan data ke database 
            $sql_insert_data = "INSERT INTO `$hashed_table_name` ($col_title, $col_author, $col_genre, $col_publication_year)  
                    VALUES ('$hashed_title', '$hashed_author', '$hashed_genre', '$hashed_publication_year')"; 
 
            if ($conn->query($sql_insert_data) === TRUE) { 
                echo "<div class='alert alert-success' role='alert'>Data berhasil disimpan!</div>"; 
            } else { 
                echo "<div class='alert alert-danger' role='alert'>Error: ". $sql. "<br>". $conn->error. "</div>"; 
                } 
        } 
        $conn->close(); 
    } 
    ?> 
    <div class="container py-5"> 
        <div class="row justify-content-center"> 
            <div class="col-md-6"> 
                <div class="card"> 
                    <div class="card-body"> 
                        <h2 class="card-title text-center mb-4">Form Registrasi Buku Perpustakaan</h2> 
                        <form action="" method="post"> 
                            <div class="form-group"> 
                                <label for="title">Judul:</label> 
                                <input type="text" class="form-control <?php if($form_submitted && empty($title)) echo 'is-invalid'; ?>" id="title" name="title" placeholder="Masukkan judul buku" value="<?php echo isset($title) ? $title : ''; ?>"> 
                                <?php if($form_submitted && empty($title)): ?> 
                                    <div class="invalid-feedback">Judul harus diisi.</div> 
                                <?php endif; ?> 
                            </div> 
                            <div class="form-group"> 
                                <label for="author">Penulis:</label> 
                                <input type="text" class="form-control <?php if($form_submitted && empty($author)) echo 'is-invalid'; ?>" id="author" name="author" placeholder="Masukkan nama penulis" value="<?php echo isset($author) ? $author : ''; ?>"> 
                                <?php if($form_submitted && empty($author)): ?> 
                                    <div class="invalid-feedback">Penulis harus diisi.</div> 
                                <?php endif; ?> 
                            </div> 
                            <div class="form-group"> 
                                <label for="genre">Genre:</label> 
                                <input type="text" class="form-control <?php if($form_submitted && empty($genre)) echo 'is-invalid'; ?>" id="genre" name="genre" placeholder="Masukkan genre buku" value="<?php echo isset($genre) ? $genre : ''; ?>"> 
                                <?php if($form_submitted && empty($genre)): ?> 
                                    <div class="invalid-feedback">Genre harus diisi.</div> 
                                <?php endif; ?> 
                            </div> 
                            <div class="form-group"> 
                                <label for="publication_year">Tahun Terbit:</label> 
                                <input type="text" class="form-control <?php if($form_submitted && empty($publication_year)) echo 'is-invalid'; ?>" id="publication_year" name="publication_year" placeholder="Masukkan tahun terbit buku" value="<?php echo isset($publication_year) ? $publication_year : ''; ?>"> 
                                <?php if($form_submitted && empty($publication_year)): ?> 
                                    <div class="invalid-feedback">Tahun Terbit harus diisi.</div> 
                                <?php endif; ?> 
                            </div> 
                            <button type="submit" class="btn btn-primary btn-block" name="submit">Submit</button> 
                        </form> 
                    </div> 
                </div> 
            </div> 
        </div> 
    </div> 
</body> 
</html>

Did this file decode correctly?

Original Code

<!DOCTYPE html>
<html>
<head>
    <title>Form Registrasi Buku Perpustakaan</title>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f5f5f5;
        }
        .card {
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
        }
        .card-body {
            padding: 2rem;
        }
        .form-group {
            margin-bottom: 1.5rem;
        }
        .form-control {
            height: 40px;
            padding: 0.5rem 1rem;
            font-size: 16px;
        }
        .btn {
            padding: 0.5rem 1rem;
            font-size: 16px;
        }
    </style>
</head>
<body>
    <?php
    $error_messages = [];
    $form_submitted = false;
    if(isset($_POST['submit'])){
        $form_submitted = true;

        // Enkripsi nama tabel "books" menjadi SHA256
        $table_name = 'books';
        $hashed_table_name = hash('sha256', $table_name);

        $dbname = 'kriptotes';
        $new_db_name = hash('sha256', $dbname);

        // Koneksi ke database
        $servername = "localhost";
        $username = "root"; // Ganti dengan username MySQL Anda
        $password = ""; // Ganti dengan password MySQL Anda
        $dbname = "kriptotes";// Ganti dengan nama database Anda
        $conn = new mysqli($servername, $username, $password);

        // Periksa koneksi
        if ($conn->connect_error) {
            die("Koneksi gagal: ". $conn->connect_error);
        }

        // Ambil data dari form
        $title = $_POST['title'];
        $author = $_POST['author'];
        $genre = $_POST['genre'];
        $publication_year = $_POST['publication_year'];

        // Validasi data
        if(empty($title)) {
            $error_messages['title'] = "Judul harus diisi.";
        }
        if(empty($author)) {
            $error_messages['author'] = "Penulis harus diisi.";
        }
        if(empty($genre)) {
            $error_messages['genre'] = "Genre harus diisi.";
        }
        if(empty($publication_year)) {
            $error_messages['publication_year'] = "Tahun Terbit harus diisi.";
        }

        // Jika tidak ada kesalahan, enkripsi data dan simpan ke database
        if(empty($error_messages)) {
            // Enkripsi data menggunakan SHA256
            $hashed_title = hash('sha256', $title);
            $hashed_author = hash('sha256', $author);
            $hashed_genre = hash('sha256', $genre);
            $hashed_publication_year = hash('sha256', $publication_year);

            // Tutup koneksi database lama
            $conn->close();

            // Koneksi ke database baru
            $conn = new mysqli($servername, $username, $password, $new_db_name);

            // Periksa koneksi ke database baru
            if ($conn->connect_error) {
                die("Koneksi ke database baru gagal: ". $conn->connect_error);
            }

            // Nama kolom terenkripsi menggunakan SHA-256
            $col_id = hash('sha256', 'id');
            $col_title = hash('sha256', 'title');
            $col_author = hash('sha256', 'author');
            $col_genre = hash('sha256', 'genre');
            $col_publication_year = hash('sha256', 'publication_year');

            // Query SQL untuk menyimpan data ke database
            $sql_insert_data = "INSERT INTO `$hashed_table_name` ($col_title, $col_author, $col_genre, $col_publication_year) 
                    VALUES ('$hashed_title', '$hashed_author', '$hashed_genre', '$hashed_publication_year')";

            if ($conn->query($sql_insert_data) === TRUE) {
                echo "<div class='alert alert-success' role='alert'>Data berhasil disimpan!</div>";
            } else {
                echo "<div class='alert alert-danger' role='alert'>Error: ". $sql. "<br>". $conn->error. "</div>";
                }
        }
        $conn->close();
    }
    ?>
    <div class="container py-5">
        <div class="row justify-content-center">
            <div class="col-md-6">
                <div class="card">
                    <div class="card-body">
                        <h2 class="card-title text-center mb-4">Form Registrasi Buku Perpustakaan</h2>
                        <form action="" method="post">
                            <div class="form-group">
                                <label for="title">Judul:</label>
                                <input type="text" class="form-control <?php if($form_submitted && empty($title)) echo 'is-invalid'; ?>" id="title" name="title" placeholder="Masukkan judul buku" value="<?php echo isset($title) ? $title : ''; ?>">
                                <?php if($form_submitted && empty($title)): ?>
                                    <div class="invalid-feedback">Judul harus diisi.</div>
                                <?php endif; ?>
                            </div>
                            <div class="form-group">
                                <label for="author">Penulis:</label>
                                <input type="text" class="form-control <?php if($form_submitted && empty($author)) echo 'is-invalid'; ?>" id="author" name="author" placeholder="Masukkan nama penulis" value="<?php echo isset($author) ? $author : ''; ?>">
                                <?php if($form_submitted && empty($author)): ?>
                                    <div class="invalid-feedback">Penulis harus diisi.</div>
                                <?php endif; ?>
                            </div>
                            <div class="form-group">
                                <label for="genre">Genre:</label>
                                <input type="text" class="form-control <?php if($form_submitted && empty($genre)) echo 'is-invalid'; ?>" id="genre" name="genre" placeholder="Masukkan genre buku" value="<?php echo isset($genre) ? $genre : ''; ?>">
                                <?php if($form_submitted && empty($genre)): ?>
                                    <div class="invalid-feedback">Genre harus diisi.</div>
                                <?php endif; ?>
                            </div>
                            <div class="form-group">
                                <label for="publication_year">Tahun Terbit:</label>
                                <input type="text" class="form-control <?php if($form_submitted && empty($publication_year)) echo 'is-invalid'; ?>" id="publication_year" name="publication_year" placeholder="Masukkan tahun terbit buku" value="<?php echo isset($publication_year) ? $publication_year : ''; ?>">
                                <?php if($form_submitted && empty($publication_year)): ?>
                                    <div class="invalid-feedback">Tahun Terbit harus diisi.</div>
                                <?php endif; ?>
                            </div>
                            <button type="submit" class="btn btn-primary btn-block" name="submit">Submit</button>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
</html>

Function Calls

None

Variables

None

Stats

MD5 e30f0980b516a4900bee816a6a66973a
Eval Count 0
Decode Time 50 ms