-
Notifications
You must be signed in to change notification settings - Fork 3
/
server.php
33 lines (22 loc) · 854 Bytes
/
server.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
<?php
header('Access-Control-Allow-Origin: *');
header('Content-Type: application/json');
if(!isset($_POST)) die();
session_start();
$response = [];
$con = mysqli_connect('localhost', 'root', '', 'vocational training institute');
$username = mysqli_real_escape_string($con, $_POST['username']);
$password = mysqli_real_escape_string($con, $_POST['password']);
$query = "SELECT * FROM `user_tbl` WHERE Username='$username' AND Password='$password'";
$result = mysqli_query($con, $query);
$row = mysqli_fetch_array($result);
if(mysqli_num_rows($result) > 0) {
$response['status'] = 'loggedin';
$response['user'] = $username;
$response['Type'] = $row[3];
$response['useruniqueid'] = md5(uniqid());
$_SESSION['useruniqueid'] = $response['useruniqueid'];
}else{
$response['status'] = 'error';
}
echo json_encode($response);