-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.php
41 lines (27 loc) · 967 Bytes
/
login.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
<?php
include_once('dbconnection.php');
if (isset($_POST['submit'])) {
//fetch from htmla
$UserName = $_POST["UserName"];
$Password = $_POST['Password'];
$query1 = "SELECT * FROM `membership` WHERE UserName= '$UserName'";
$duplicate = mysqli_query($con, $query1);
//Selection from database
$query = "SELECT `Password` FROM `membership` where UserName='$UserName';";
$result = mysqli_query($con, $query);
$row = mysqli_fetch_assoc($result);
if (mysqli_num_rows($result) > 0) {
//Confirmation check
if ($Password == $row['Password']) {
$_SESSION['login'] = true;
$_SESSION['name'] = $row['UserName'];
$_SESSION['Pass'] = $UserName;
header("location:index.php");
} else {
echo "<script>alert('Wrong password');</script>";
}
} else {
echo "<script>alert('User not registered');</script>";
}
}
?>