-
Notifications
You must be signed in to change notification settings - Fork 0
/
logintest.php
87 lines (63 loc) · 1.31 KB
/
logintest.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
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<?php
if(isset($_POST['submit']))
{
if(!isset($_SESSION))
{
session_start();
}
if (!IsSet($_SESSION["username"])) {
$_SESSION["username"]= "Login";}
$error="";
if (empty($_POST['username']) || empty($_POST['password'])) {
$error = "Username or Password is invalid";
}
else {
$username12=$_POST["username"];
$password12=$_POST["password"];
$servername="localhost";
$username="root";
$password="";
$db="toystoredb";
$con=mysqli_connect($servername,$username,$password,$db);
if(!$con)
{
die("connaction die".mysql_error());
}
//echo "connection sucessfull<br>";
$sql = "select * from user where password='$password12' AND username='$username12'";
$result = $con->query($sql);
if ($result->num_rows > 0) {
// echo "You Have Logged In successfully";
$_SESSION["username"] = $username12;
while($row = $result->fetch_assoc()) {
if(!strcmp($row['type'],"1"))
{
$_SESSION["users"] = "client";
include( 'prof.php');
break;
}
else
{
$_SESSION["users"] = "admin";
include( 'adminprof.php');
break;
}
}
} else {
echo "wrong";
header( "refresh:1;url=p2.html" );
}
mysqli_close($con);
}}
else {
echo "wrongggg";
}
?>
</body>
</html>