-
Notifications
You must be signed in to change notification settings - Fork 0
/
logging_in.php
103 lines (52 loc) · 1.31 KB
/
logging_in.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
<?PHP
if(isset($_REQUEST["email"]) AND isset($_REQUEST["password"]))
{
//KALAU email dan password sudah diset
//LOAD email sama password
$email=$_REQUEST["email"];
$password=$_REQUEST["password"];
//ANTI CROSS SITE SCRIPTING
$email=htmlspecialchars($email);
$password=htmlspecialchars($password);
//CONNECT KE MYSQL
$db_tabel_user="data_user";
require "koneksi_ke_mysql.php";
if (!$link)
{
die("Gagal tersambung!");
}
else
{
$search=
mysqli_query(
$link,
"SELECT * FROM ".$db_tabel_user."
WHERE email='".$email."';");
$cekpassword=mysqli_fetch_array($search,MYSQLI_ASSOC);
if (mysqli_num_rows($search)==1)
{
if ($password==$cekpassword["password"])
{
session_start();
$_SESSION["email"]=$email;
$_SESSION["logged_in"]=true;
header("location:home.php");
}
else
{
$pesan="Login gagal! Periksa alamat email dan/atau password Anda!<br>Silahkan ulangi";
header("location:index.php?status=passwordsalah");
}
}
else
{
$pesan="Email tidak terdaftar! Silahkan <a href='buatakun.php'>buat akun</a>";
header("location:index.php?status=tidakterdaftar");
}
}
}
else
{
header("location:index.php");
}
?>