Insert data into 2 different tables


#1

i am new with this stuff please be nice :slight_smile:
I want to create a application where one account is linked to 2 persons.
I have this database :

Table account_info : acc_id (primary key) , a_username(foreign key), p_username(foreign key).

Table admin_info : a_username (primary key) , acc_id(foreign key), and more fields…

Table patient_info : p_username (primary key) , acc_id(foreign key), and more fields…

i have tried this code :

switch($key)
{
  // Add a new record to the technologies table
  case "create":

     // Sanitise URL supplied values
     $a_username    = filter_var($_REQUEST['a_username'], 
FILTER_SANITIZE_STRING, FILTER_FLAG_ENCODE_LOW);
     $p_username    = filter_var($_REQUEST['p_username'], 
FILTER_SANITIZE_STRING, FILTER_FLAG_ENCODE_LOW);
	 $password      = filter_var($_REQUEST['password'], 
FILTER_SANITIZE_STRING, FILTER_FLAG_ENCODE_LOW);
 
     // Attempt to run PDO prepared statement
     try {
        $sql  = "	INSERT INTO account_info(password) VALUES(:password);
						INSERT INTO 
admin_info(a_username)VALUES(:a_username);
							INSERT INTO 
patien_info(p_username)VALUES(:p_username);
				";
				
        $stmt    = $pdo->prepare($sql);
        $stmt->bindParam(':a_username', $a_username, PDO::PARAM_STR);
        $stmt->bindParam(':p_username', $p_username, PDO::PARAM_STR);
		$stmt->bindParam(':password', $password, PDO::PARAM_STR);
	
        $stmt->execute();

        echo json_encode(array('message' => 'Congratulations the Account was 
added to the database'));
     }
     // Catch any errors in running the prepared statement
     catch(PDOException $e)
     {
        echo $e->getMessage();
     }

  break;
}

but nothing showed in the database.
Can anyone direct me in the right way please??