· 5 years ago · Jun 18, 2020, 03:28 AM
1<?php
2session_start();
3
4include "include/konek_db.php";
5
6$hal=$_GET['php'];
7$act=$_GET['act'];
8$tanggal=date("Y-m-d H:i:s");
9
10
11if ($hal=='transaksi' AND $act=='input'){
12 $rand = rand();
13 $ekstensi = array('png','jpg','jpeg','gif');
14 $filename = $_FILES['fupload']['name'];
15 $ukuran = $_FILES['fupload']['size'];
16 $ext = pathinfo($filename, PATHINFO_EXTENSION);
17
18 $secret_key = "6LdNRqUZAAAAAIdgopcajetYq8Ny-AvdOFUMaWWQ";
19
20 $verify = file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret='.$secret_key.'&response='.$_POST['g-recaptcha-response']);
21 $response = json_decode($verify);
22
23 if (!is_numeric($_POST['idnaskah'])){
24 echo "<script>window.alert('Pada ID nashkah terdapat huruf. Mohon diulangi.');
25 window.location=('index.php')</script>";
26 }
27 elseif(!in_array($ext,$ekstensi) ) {
28 echo "<script>window.alert('Upload Gagal, Pastikan File yang di Upload bertipe *.JPG');
29 window.location=('index.php')</script>";
30 }
31 elseif($ukuran > 1044070){
32 echo "<script>window.alert('Size gambar terlalu besar.');
33 window.location=('index.php')</script>";
34 }
35
36 elseif ($response->success){
37
38 $xx = $rand.'_'.$filename;
39 move_uploaded_file($_FILES['fupload']['tmp_name'], 'pict/'.$rand.'_'.$filename);
40
41 $noinvoice = $_POST['noinvoice'];
42 $idnaskah = $_POST['idnaskah'];
43 $judul_naskah = $_POST['judul'];
44 $nama_lengkap = $_POST['nama'];
45 $email = $_POST['email'];
46 $metode_bayar = $_POST['metode'];
47 $total_bayar = $_POST['total_bayar'];
48
49 mysqli_query($conn, "INSERT INTO transaksi (noinvoice,
50 idnaskah,
51 judul_naskah,
52 nama_lengkap,
53 email,
54 metode_bayar,
55 total_bayar,
56 bukti_bayar,
57 tanggal_verifikasi)
58 VALUES('$noinvoice',
59 '$idnaskah',
60 '$judul_naskah',
61 '$nama_lengkap',
62 '$email',
63 '$metode_bayar',
64 '$total_bayar',
65 '$xx',
66 '$tanggal')");
67 echo "<script> document.location.href='home.php?php=verifikasi&no=$noinvoice'; </script>";
68 } else {
69 echo "<script>window.alert('Captcha tidak berhasil.');
70 window.location=('index.php')</script>";
71 }
72
73}
74
75?>