<?php
// register.php
header("Content-Type: application/json");
$servername = "localhost";
$username = "myprojec_allytec";
$password = "allytech@2019";
$dbname = "myprojec_patient";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $data = json_decode(file_get_contents("php://input"));

    $name = $data->Name;
    $emailid = $data->emailid;
    $contactno = $data->contactno;
    $password =$data->password;

    $sql = "INSERT INTO usertbl (Name, emailid, contactno, password) VALUES ('$name', '$emailid', '$contactno', '$password')";

    if ($conn->query($sql) === TRUE) {
        echo json_encode(['message' => 'User registered successfully']);
    } else {
        echo json_encode(['message' => 'Error: ' . $conn->error]);
    }
}

$conn->close();
?>
