-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinput2.php
More file actions
47 lines (36 loc) · 1.03 KB
/
input2.php
File metadata and controls
47 lines (36 loc) · 1.03 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
36
37
38
39
40
41
42
43
44
45
46
47
<?php
// Aktifkan error reporting
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
// Koneksi database
$conn = mysqli_connect("localhost", "root", "", "databasepfs");
// Cek koneksi
if (!$conn) {
die("Koneksi gagal: " . mysqli_connect_error());
}
// Ambil data dari form login
$email = $_POST['email'];
$password = $_POST['password'];
// Cek email dan password di tabel users
$sql = "SELECT * FROM users WHERE email='$email' AND password='$password'";
// Query sql
$result = mysqli_query($conn, $sql);
// Hitung jumlah data
$count = mysqli_num_rows($result);
// Cek apakah ada data
// Logika login seperti semula...
if($count > 0) {
echo "<script>
alert('Login Berhasil!');
</script>";
echo '<meta http-equiv="refresh" content="0;url=home.html">';
exit();
} else {
// Login gagal
echo "<script>
alert('Login gagal! Silakan coba lagi');
window.location='index2.html';
</script>";
}
?>