-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.php
executable file
·41 lines (34 loc) · 961 Bytes
/
login.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
<?php
require "functions/db.php";
require "functions/users.php";
if (isset($_POST['mobile']) && is_numeric($_POST['mobile']))
$mobile = $_POST['mobile'];
else
{
echo 'Invalid Mobile number';
exit();
}
if (isset($_POST['password']))
$password=md5($_POST['password']);
else
{
echo 'Please enter password';
exit();
}
$sql = "SELECT user_id FROM users WHERE password='$password' AND phone_number='$mobile' ";
$res = mysqli_query($conn, $sql);
$password_check = mysqli_num_rows($res);
if($password_check>0){
$result=mysqli_query($conn, "SELECT * from users WHERE phone_number='$mobile' AND password='$password' ");
$row = $result -> fetch_assoc();
unset($row["password"]);
//echo json_encode( array("mobile" => $row["phone_number"], "name" => $row["first_name"].$row["last_name"]) );
array_walk_recursive($row, function (&$item, $key) {
$item = null === $item ? '' : $item;
});
echo json_encode($row);
}
else
{echo 'Invalid Credentials';
}
?>