0

I am new to PHP.

I have a code that creates a simple POST Request to send name and email as follows:

$conn = mysqli_connect($servername, $username, $password, $database);

if (!$conn) {
    die("Connection failed: " . mysqli_connect_error());
} 

$name = ($_POST['name']);
$email = ($_POST['email']);

name and email are always empty.

This script is hosted on a subdomain https://developer.xyz.com/api-v1/insertsubscriber/ (with SSL) and the xyz.com domain also has an SSL. And no redirection exists.

The request is called from postman as:

POST /api-v1/insertsubscriber/ HTTP/1.1
Host: developer.xyz.com
Content-Type: application/json
Content-Length: 45

{"name":"myname",
"email":"myemail@meme.com"}

And also tried to disable CORS:

header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: POST, GET');
header('Access-Control-Allow-Headers: token, Content-Type');

What might be causing the problem?

DevAntho
  • 39
  • 3

0 Answers0