无法将我的PHP代码连接到数据库 - Android Studio

I don't know the best way to ask you this question, but I am using Android Studio, phpMyAdmin, MySQL and the PostMan plugin to debug my php files.

I am trying to create an app that will take user registration and login, and am having problems trying to register a user. The following error I'm getting in Android Studio:

org.json.JSONException: Value Error of type java.lang.String cannot be converted to JSONObject

This Value "Error" regards to my PHP file, which is returning a String because it is complaining about my sql query (or that is how I understood it?):

<?php
$servername = "my server";
$username = "my user";
$password = "my password";
$dbname = "my db";

try {    

$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

// prepare sql and bind parameters
$stmt = $conn->prepare("INSERT INTO User (username, email, passcode) 
VALUES (:username, :email, :passcode)");
$stmt->bindParam(':username', $username);
$stmt->bindParam(':email', $email);
$stmt->bindParam(':passcode', $passcode);



$stmt->execute();

}
catch(PDOException $e)
{
echo "Error: " . $e->getMessage();
}
$conn = null;
?>

Now, the error I'm getting from PostMan is this:

Error: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'email' cannot be null

I don't know how to properly handle this...

This isn't an error with PHP, it is with your database. In your table structure you are not allowing the email field to have a null value but you are sending a null value in your php $email value.

the Variable $email is not initialized so it's null.

Your table constraint does not allow null-values in the email column