/
UserDetails.php
49 lines (41 loc) · 1.18 KB
/
UserDetails.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
<?php
function checkUserCredentals($inputUsername, $inputPassword)
{
/*
This function takes input username and password as parameters and
returns TRUE if the user is authenticated, FALSE if the user is not authenticated
*/
// create connection
$mysqli = new mysqli("localhost", "VEDB01", "04051991", "VEDB01mysql1");
if ($mysqli->connect_errno) {
echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}
// query the users table for name and surname
$sql = "SELECT UserName, Password, Status FROM Users Where UserName ='".$inputUsername."' AND Password ='".$inputPassword."' AND Status='Available'";
// perform the query
$rs = $mysqli->query($sql);
// execute SQL statement and get results
if (!$rs) {
echo "SQL operation failed: (" . $mysqli->errno . ") " . $mysqli->error;
}
//else{
//echo "Login is Successful !";
//}
//Count the record number
$counter = 0;
while ($row = $rs->fetch_assoc())
{
$counter++;
}
if ($counter>0)
{
//authentication succeeded
return (true);
}
else
{
//authentication failed
return (false);
}
}
?>