Registration Form with confirmation or welcome email after sign up

Hi guys, this is my first post on the forum and I am in need of some help. I am a PHP beginner and I have been trying to come up with a solution to my issue for a while now. I am trying to make a system where a user registers and after the submit button is pressed a welcome message is displayed on the screen along with a confirmation email. This is where I am struggling. I got my registeration system working however integrating this with the confirmation email is very difficult and I don't understand how to structure this at all. I would be very grateful is somebody could help me out. Thank you!

`<?php
include 'form.html.php';
require_once('SMTP.php');
require_once('PHPMailer.php');
require_once('Exception.php');
use \PHPMailer\PHPMailer\PHPMailer;
use \PHPMailer\PHPMailer\Exception;

//insert new user
if (isset($_GET['addform']))

{
    include '../admin/includes/db.inc.php';
    try
    {
        $sql = 'INSERT INTO author SET name = :name, email = :email, password = :password';
        $s = $pdo->prepare($sql);
        $s->bindvalue(':name', $_POST['name']);
        $s->bindvalue(':email', $_POST['email']);
        $s->bindvalue(':password', md5($_POST['password']. '')); //MY SALT IS MEANT TO BE WITHIN THE '' AT THE END
        $s->execute();
    }
    catch (PDOException $e)
    {
        $error = 'Error with registration.';
        include 'error.html.php';
        exit();
    }

    $mail=new PHPMailer(true); // Passing `true` enables exceptions

try {
    //settings
    $mail->isSMTP(); // Set mailer to use SMTP
    $mail->Host='smtp.gmail.com';
    $mail->SMTPAuth=true; // Enable SMTP authentication
    $mail->Username=''; // SMTP username - MY DETAILS GO HERE 
    $mail->Password=''; // SMTP password - MY DETAILS GO HERE 
    $mail->SMTPSecure='ssl';
    $mail->Port=465;

    $mail->setFrom(''); //MY DETAILS GO HERE  

    //recipient
    $mail->addAddress('');     // Add a recipient //MY DETAILS GO HERE  

    //content
    $mail->isHTML(true); // Set email format to HTML
    $mail->Subject='Registeration Successful';
    $mail->Body='Thank You for registering with us. We hope to see you soon! <b>Happy Cooking</b>';
    $mail->AltBody='This is the body in plain text for non-HTML mail clients';

    $mail->send();

    echo 'Message has been sent';
} 
catch(Exception $e) {
    echo 'Message could not be sent.';
    echo 'Mailer Error: '.$mail->ErrorInfo;
}



    $authorid = $pdo->lastInsertId();
    try
    {
        $sql = 'INSERT INTO authorrole SET 
        authorid = :authorid, 
        roleid = :roleid';
        $s = $pdo->prepare($sql);
        $s->bindvalue(':authorid', $authorid);
        $s->bindvalue(':roleid', 'User');
        $s->execute();
    }
    catch (PDOException $e)
    {
        $error = 'Error assigning selected role to user.';
        include 'error.html.php';
        exit();
    }
    header('Location:welcome.html.php');
}`