-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmail.php
executable file
·99 lines (62 loc) · 2.3 KB
/
mail.php
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?php
session_start();
error_reporting(0);
include 'setting/server.php';
if (isset($_POST['submit'])) {
$username =htmlspecialchars($_POST['username']);
$email = htmlspecialchars($_POST['email']);
$nama = htmlspecialchars($_POST['nama']);
$pass1= md5 (trim($_POST['pass1']));
$pass2= md5 (trim($_POST['pass2']));
if (trim($pass1) != trim($pass2)) {
echo "<script>window.alert('Password Harus sama');</script>";
echo "<script>window.location ='daftar.php';</script>";
//echo "Sepertinya Password Anda Tidak Sama";
//include_once 'daftar.php';
//die("Silahkan Coba Lagi");
}elseif (trim($username)=="") {
echo "<script>window.alert('Data Berhasil Di Hapus');</script>";
echo "<script>window.location ='../produk.php';</script>";
echo "Username Jangan Sampai Kosong";
//include_once 'daftar.php';
//die("Silahkan Coba Lagi");
}elseif (trim($email)=="") {
echo "Email Masih Kosong";
include_once 'daftar.php';
die("Silahkan Coba Lagi");
}else{
$username = strtolower($username);
$cek_user = $conn->query("SELECT * FROM login WHERE username='$username'");
if ($cek_user->num_rows > 0) {
echo "Username<br/>".$username."<br/>Sudah Ada";
include_once 'daftar.php';
$conn->close();
}else{
define('ROOT', 'http://127.0.0.1/1/');
$kode = md5(uniqid(rand(),TRUE));
$konfirmasi = "INSERT INTO login (username,email,nama,password,confirm,kode,role,foto) VALUES('$username','$email','$nama','$pass1','N','$kode','2','avatar.png')";
if ($conn->query($konfirmasi)===TRUE) {
}else{
die("ERROR".$konfirmasi."<br>".$conn->error);
}
$to = $_POST['email'];
$judul = "Aktivasi Akun Anda";
$dari = "From: admin@bengkel.com \n";
$dari .= "Content-type: text/html \r\n";
$pesan = "Klik link berikut untuk mengaktifkan akun Anda: <br/>";
$pesan .= "<a href='".ROOT."confirm.php?email=".$_POST['email']."&kode=$kode&username=".$_POST['username']."'>".ROOT."confirm.php?email=".$_POST['email']."&kode=$kode</a>
Salam<br/>
Bengkel Online";
$kirim = mail($to, $judul, $pesan, $dari);
if($kirim){
echo "<script language='JavaScript'>alert('Sebuah Email Telah dikirim Ke Akun Anda Cek Sekarang');
window.location='index.php';
</script>"
;
}else{
echo "Gagal Mengirim";
}
}
}
}
?>