· last year · Jan 21, 2024, 03:15 PM
1<?php
2include("security.php");
3$conn = mysqli_connect("localhost", "icwr", "icwr", "form_pendaftaran");
4 ?>
5<!doctype html>
6<html lang="en">
7 <head>
8 <meta charset="utf-8">
9 <meta name="viewport" content="width=device-width, initial-scale=1">
10 <title>Bootstrap demo</title>
11 <link href="dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
12 <script src='https://www.google.com/recaptcha/api.js'></script>
13 <style>
14 /* Custom CSS jika diperlukan */
15 body {
16 height: 100vh;
17 margin: 0;
18 display: flex;
19 align-items: center;
20 justify-content: center;
21 }
22 </style>
23 </head>
24 <body>
25 <div class="container mt-3">
26 <div class="card">
27 <div class="card-title text-center mt-3">
28 <h2>Forumulir pendaftaran</h2>
29 </div>
30 <div class="card-body shadow">
31 <form method="post" enctype="application/x-www-form-urlencoded">
32 <label for="nama"> <strong>Nama: </strong> </label>
33 <input type="text" name="nama" value="" placeholder="Nama..." class="form-control" id="nama">
34 <label for="no_telepon" class="mt-3"> <strong>No telepon:</strong> </label>
35 <input type="text" name="no" value="" placeholder="No telepon..." class="form-control" id="no_telepon">
36 <div class="mt-3">
37 <div class="g-recaptcha" data-sitekey="6LfDz1cpAAAAAFVQIKikA8rIxXXcHfXhysPZ1waZ"></div>
38 </div>
39 <input type="submit" name="submit" value="Submit" class="btn btn-secondary col-md-12 mt-3">
40 </form>
41 <?php
42 $secret_key = "6LfDz1cpAAAAANhlyY2WIx9HVPVvoN7T1csWgCab";
43 $verify = file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret='.$secret_key.'&response='.$_POST['g-recaptcha-response']);
44 $response = json_decode($verify);
45 if($_POST){
46 if($response->success){
47 $nama = $_POST['nama'];
48 $no_telepon = $_POST['no'];
49 $tanggal = formatDate();
50 $query = "INSERT INTO daftar(nama, no_telpon, tanggal) VALUES('$nama', '$no_telepon', '$tanggal')";
51 if (mysqli_query($conn, $query)) {
52 ?>
53 <div class="alert alert-success mt-3">
54 Berhasil mendaftar Mini Gathering In Crust We Rush!
55 </div>
56 <?php
57 }else{
58 ?>
59 <div class="alert alert-success mt-3">
60 Gagal mendaftar Mini Gathering In Crust We Rush, silahkan hubungi kontak pribadi!
61 </div>
62 <?php
63 }
64 }else{
65 ?>
66 <div class="alert alert-danger mt-3">
67 Captcha tidak valid!
68 </div>
69 <?php
70 }
71 }
72 function formatDate() {
73 date_default_timezone_set('Asia/Jakarta');
74 $formattedDate = date("d-m-Y H:i:s");
75 return $formattedDate;
76 }
77 ?>
78 </div>
79 </div>
80 </div>
81 <script src="dist/js/bootstrap.bundle.min.js" integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous"></script>
82 </body>
83</html>
84