-
Notifications
You must be signed in to change notification settings - Fork 0
/
pharmaLogin.php
126 lines (106 loc) · 3.87 KB
/
pharmaLogin.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Pharmacy Login</title>
<!-- <link rel="stylesheet" href="src/styles.css">
<link rel="stylesheet" href="src/styles1.css"> -->
<!-- Font Icon -->
<link rel="stylesheet" href="src/login/fonts/material-icon/css/material-design-iconic-font.min.css">
<!-- Main css -->
<link rel="stylesheet" href="src/login/css/style.css">
</head>
<body>
<?php
session_start(); //start the session
$pass=$uname=$name="";
$status=true;
if (!empty($_POST)) {
if (empty($_POST['uname'])) {
$status=false;
}
else {
$uname=$_POST['uname'];
}
if (empty($_POST['name'])) {
$status=false;
}
else {
$name=$_POST['name'];
}
if (empty($_POST['password'])) {
$status=false;
}
else {
$pass=sha1($_POST['password']);
}
$servername= "localhost";
$username= "root";
$password= "";
$dbname="electrothon";
//create connection
$com= new mysqli($servername, $username, $password,$dbname);
//check connection
if ($com->connect_error ) {
die("Connection failed ".$com->connect_error);
}
else{
if ($status) {
$sql="SELECT *
FROM pharmalogin WHERE name='$name' && username='$uname' && password='$pass'";
$result=$com->query($sql);//finding out how many rows are being returned
if ($result->num_rows > 0) {
$record= $result->fetch_assoc();//converting result to associative array
$_SESSION['loggedin1']=true; //loggedin can be anything
$_SESSION['userDetails1']=$record;
header ("Location: pharma.php");
}
else{
echo "Invalid credentials. <br>";
}
$com->close();
}
}
}
?>
<!-- <div class="wrap">
<h1>Login</h1>
<form method="POST">
<p>Hospital name:</p>
<input type="text" name="name" placeholder="Name"><br>
<p>Username:</p>
<input type="text" name="uname" placeholder="Username"><br>
<p>Password:</p>
<input type="password" name="password" placeholder="Password"><br>
<input type="submit" name="submit" value="Login">
</form>
</div> -->
<div class="main">
<section class="signup">
<!-- <img src="images/signup-bg.jpg" alt=""> -->
<div class="container">
<div class="signup-content">
<form method="POST" id="signup-form" class="signup-form">
<h2 class="form-title">Pharmacy Login</h2>
<div class="form-group">
<input type="text" class="form-input" name="name" id="name" placeholder="Name"/>
</div>
<div class="form-group">
<input type="text" class="form-input" name="uname" id="name" placeholder="Username"/>
</div>
<div class="form-group">
<input type="password" class="form-input" name="password" id="password" placeholder="Password"/>
</div>
<div class="form-group">
<input type="submit" name="submit" id="submit" class="form-submit" value="Login"/>
</div>
</form>
</div>
</div>
</section>
</div>
<script src="src/login/js/main.js"></script>
</body>
</html>