-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimpanbiodata.php
More file actions
35 lines (29 loc) · 1.06 KB
/
simpanbiodata.php
File metadata and controls
35 lines (29 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
include "config/koneksi.php";
$nama=$_POST['nama'];
$phone=$_POST['phone'];
$email=$_POST['email'];
$gender=$_POST['gender'];
$ekstensi_diperbolehkan = array('png','jpg');
$filenama = $_FILES['filefoto']['name'];
$x = explode('.', $filenama);
$ekstensi = strtolower(end($x));
$file_tmp = $_FILES['filefoto']['tmp_name'];
$filefoto = 'upload/'.$filenama;
if(in_array($ekstensi, $ekstensi_diperbolehkan) === true)
{
move_uploaded_file($file_tmp, 'upload/'.$filenama);
}
else
{
echo "<script>alert('Gagal menambahkan data. ISI DENGAN BENAR'); document.location='addbiodata.php';</script>";
exit();
};
$sql = "INSERT INTO biodata (nama, phone, email, foto, gender)
VALUES ('$nama','$phone','$email','$filefoto','$gender')";
if ($conn->query($sql) === TRUE) {
echo "<script>alert('Data Telah Disimpan'); document.location='addbiodata.php';</script>";
} else {
echo "<script>alert('Data Gagal Disimpan'); document.location='addbiodata.php';</script>";
};
?>