-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTest1.php
87 lines (77 loc) · 1.65 KB
/
Test1.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
<?php
// Start the session
session_start();
?>
<html>
<body>
<?php
$conn = mysqli_connect("localhost", "root", "", "bankdb");
if (!$conn)
{
die("Connection failed: " . mysqli_connect_error());
}
//$sql = "select UserId from userinfo";
$_SESSION["id"] = $_REQUEST['uid'];
echo "Session variables are set.";
function getJSONFromDB($sql)
{
$conn = mysqli_connect("localhost", "root", "","bankdb");
//echo $sql;
$result = mysqli_query($conn, $sql)or die(mysqli_error($conn));
$arr=array();
while($row = mysqli_fetch_assoc($result)) {
$arr[]=$row;
}
return json_encode($arr);
}
$jd=getJSONFromDB("select UserId from userinfo");
echo $jd;
$jsn=json_decode($jd);
//echo "<pre>";print_r($jsn);echo "</pre>";
for($i=0;$i<sizeof($jsn);$i++)
{
if($jsn[$i]->UserId == $_REQUEST['uid'])
{
//echo "user id matched\n" ;
break;
}
if($i == (sizeof($jsn)-1))
{
echo "user-id doesnot match" ;
}
}
$jd1=getJSONFromDB("select Password from userinfo");
//echo $jd1;
$jsn1=json_decode($jd1);
//echo "<pre>";
//print_r($jsn1);
//echo "</pre>";
for($i=0;$i<sizeof($jsn1);$i++)
{
if($jsn1[$i]->Password == $_REQUEST['pass'])
{
//echo "Password matched" ;
header('Location:homepage.html');
break;
}
if($i == (sizeof($jsn)-1))
{
echo "Password doesnot match" ;
}
}
//$res = mysql_query ($sql);
//$row = mysql_fetch_array ($res);
/*
if(mysqli_query($conn, $sql))
{
//if (!strcmp ($row['UserId'], $_REQUEST['uid']))
//{
echo "UserId doesnot match" ;
//}
//else
//echo "UserId match" ;
}
*/
?>
</body>
</html>