-
Notifications
You must be signed in to change notification settings - Fork 0
/
Signin.php
28 lines (25 loc) · 942 Bytes
/
Signin.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
<?php
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Methods: GET, POST");
header("Access-Control-Allow-Headers: Content-Type");
$conn = new mysqli("127.0.0.1", "root", "", "rplayer");
$data1 = file_get_contents("php://input");
$data2 = json_decode($data1, true);
$email = mysqli_escape_string($conn, $data2['email']);
$password = $data2['password'];
$hashed_password = password_hash($password, PASSWORD_DEFAULT);
$response = "";
$query1 = "SELECT * FROM credentials WHERE email = '$email'";
$result1 = mysqli_query($conn, $query1);
if(mysqli_num_rows($result1) == 0)
{
$query2 = "INSERT INTO credentials VALUES('$email', '$hashed_password')";
$result2 = mysqli_query($conn, $query2);
$response = "Fetched";
}
else
{
$response = "Account Exists";
}
echo json_encode($response);
?>