-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.php
73 lines (44 loc) · 1.44 KB
/
index.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
<!DOCTYPE html>
<?php
session_start();
if($_SESSION['status']=="1"){
$_SESSION['logged_in']=1;
header("Location: /welcome.php");
exit();
}
?>
<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body>
<h1 id="center">Gate Networks</h1>
<a href="register.php">Register</a><hr>
<form action="" method="post">
Username:  <input type="text" name="username" id="username" required></input><br><br>
Password:  <input type="password" name="password" id="password" required></input><br><br>
<button type="submit" id="button">Sign in</button>
</form>
</body>
</html>
<?php
session_start();
include 'creds.php';
$user_name = $_POST['username'];
$_SESSION['user']="$user_name";
$user_password = $_POST['password'];
$db = mysqli_connect('localhost',$username,$password,$database) or die("<p style='color:red;'>Error connecting to MYSQL</p>");
$query = "SELECT password FROM $table WHERE name = \"$user_name\"";
//mysqli_query($db, $query) or die("<p class=\"text-align:center;\">Unable to access MYSQL</p>");
$result = mysqli_query($db, $query);
$row = mysqli_fetch_array($result);
$password=$row['password'];
if(password_verify($user_password, $password)){
$_SESSION['status'] = "1";
header("Location: /welcome.php");
exit();
}else if(!empty($user_name)){
echo "<p class=\"false\" style=\"color:white;text-align:center;\">invalid details</p>";
}
mysqli_close($db);
?>