Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //// ===============================================================================
- //// creating connection
- $servername = "";
- $username = "";
- $password = "";
- $dbname = "";
- $conn = mysqli_connect($servername, $username, $password, $dbname);
- if (!$conn)
- {
- die("Connection failed: " . mysqli_connect_error());
- }
- // catch raw data send with Content-Type header : application/json
- $json = file_get_contents('php://input');
- $data = json_decode($json);
- $sql = "SELECT u.id
- FROM user_info u
- WHERE '$data->login' = u.login AND '$data->passwd' = u.passwd";
- // execute query and check if error
- if(!($result = mysqli_query($conn, $sql)))
- {
- echo "$param Error: " . $sql . "<br>" . mysqli_error($conn);
- }
- $id = -1;
- if(mysqli_num_rows($result)>0)
- {
- $row = mysqli_fetch_assoc($result);
- $id = $row['id'];
- }
- $id = array("id"=>$id);
- echo json_encode($id);
- mysqli_close($conn);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement