-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauthentication.php
More file actions
47 lines (39 loc) · 882 Bytes
/
authentication.php
File metadata and controls
47 lines (39 loc) · 882 Bytes
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
session_start();
$login = $_POST['login'];
$password1 = $_POST['password'];
$flag=0;
$servername ='localhost';
$username='root';
$password='';
$dbname='base1';
$con= new mysqli($servername,$username,$password, $dbname);
if ($con->connect_error){
die('error');
}
$sql="SELECT * FROM users ";
$result=$con->query($sql);
if($result->num_rows>0){
while($row=$result->fetch_assoc()){
if($row['login']==$login){
$flag=1;
if($row['password']==$password1){
$_SESSION['login'] = $login;
$_SESSION['au']=$row['group_au'];
header("Location: index.php");
break;
return;
}else{
unset($_SESSION['login']);
header("Location: index.php");
session_destroy();
return;
}
}
}}
if($flag==0){
unset($_SESSION['login']);
header("Location: index.php");
session_destroy();
}
?>