<?php
session_start();
require 'header.php';


date_default_timezone_set('Asia/Jakarta');
$tanggal = date("l, d-m-Y h:i:s:a");

if (isset($_POST["submit"])) {
    // ambil data dari tiap elemen dalam form

    //cek apakah data berhasil di ubah atau tidak
    if (buat_pesan($_POST) > 0) {
        echo "
            <script>
            alert('Pesan berhasil dikirimkan!');
            document.location.href = 'index.php';
            </script>
            ";
    } else {
        var_dump($_POST);
    }
}

?>
<html>

<head>
    <title>Membuat Contact Form dengan PHP - ePlusGo</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            -webkit-box-sizing: border-box;
            -moz-box-sizing: border-box;
            -webkit-font-smoothing: antialiased;
            -moz-font-smoothing: antialiased;
            -o-font-smoothing: antialiased;
            text-rendering: optimizeLegibility;
        }

        body {
            font-weight: 100;
            line-height: 30px;
            color: #777;

        }

        .container {
            width: 100%;
            margin: 0 auto;
            position: relative;
        }

        #contact input[type="text"],
        #contact input[type="email"],
        #contact input[type="tel"],
        #contact input[type="url"],
        #contact textarea,
        #contact button[type="submit"] {
            font: 400 12px/16px "Roboto", Helvetica, Arial, sans-serif;
        }

        #contact {
            background: #F9F9F9;
            padding: 25px;
            margin: 150px 0;
            box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.2), 0 5px 5px 0 rgba(0, 0, 0, 0.24);
        }

        #contact h3 {
            display: block;
            font-size: 30px;
            font-weight: 300;
            margin-bottom: 10px;
        }

        #contact h4 {
            margin: 5px 0 15px;
            display: block;
            font-size: 13px;
            font-weight: 400;
        }

        fieldset {
            border: medium none !important;
            margin: 0 0 10px;
            min-width: 100%;
            padding: 0;
            width: 100%;
        }

        #contact input[type="text"],
        #contact input[type="email"],
        #contact input[type="tel"],
        #contact input[type="url"],
        #contact textarea {
            width: 100%;
            border: 1px solid #ccc;
            background: #FFF;
            margin: 0 0 5px;
            padding: 10px;
        }

        #contact input[type="text"]:hover,
        #contact input[type="email"]:hover,
        #contact input[type="tel"]:hover,
        #contact input[type="url"]:hover,
        #contact textarea:hover {
            -webkit-transition: border-color 0.3s ease-in-out;
            -moz-transition: border-color 0.3s ease-in-out;
            transition: border-color 0.3s ease-in-out;
            border: 1px solid #aaa;
        }

        #contact textarea {
            height: 100px;
            max-width: 100%;
            resize: none;
        }

        #contact button[type="submit"] {
            cursor: pointer;
            width: 100%;
            border: none;
            background: #4CAF50;
            color: #FFF;
            margin: 0 0 5px;
            padding: 10px;
            font-size: 15px;
        }

        #contact button[type="submit"]:hover {
            background: #43A047;
            -webkit-transition: background 0.3s ease-in-out;
            -moz-transition: background 0.3s ease-in-out;
            transition: background-color 0.3s ease-in-out;
        }

        #contact button[type="submit"]:active {
            box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5);
        }

        .copyright {
            text-align: center;
        }

        #contact input:focus,
        #contact textarea:focus {
            outline: 0;
            border: 1px solid #aaa;
        }

        ::-webkit-input-placeholder {
            color: #888;
        }

        :-moz-placeholder {
            color: #888;
        }

        ::-moz-placeholder {
            color: #888;
        }

        :-ms-input-placeholder {
            color: #888;
        }

        .notify {
            padding: 10px;
            background-color: #FFD76E;
            margin-bottom: 10px;
            border-radius: 3px;
            font-weight: bold;
        }
    </style>
</head>

<body>
    <div class="container">
        <form id="contact" action="" method="post">
            <input type="hidden" name="tanggal" id="tanggal" value="<?= $tanggal; ?>">
            <h3>Contact Form</h3>
            <h4>Hubungi kami dengan mengisi isian dibawah</h4>
            <fieldset>
                <input placeholder="Nama Anda" type="text" name="nama" id="nama" required autofocus>
            </fieldset>
            <fieldset>
                <input placeholder="Email Anda" type="email" name="email" id="email" required>
            </fieldset>
            <fieldset>
                <input placeholder="Subject (optional)" type="text" name="subjek" id="subjek" required>
            </fieldset>
            <fieldset>
                <textarea placeholder="Ketikan pesan Anda" name="pesan" id="pesan" required></textarea>
            </fieldset>
            <fieldset>
                <button name="submit" type="submit" id="submit">Kirim</button>
            </fieldset>
        </form>
    </div>
</body>

</html>
<?php
require 'footer.php';
?>